Compare two properties of the same object in the Where clause of RavenDb

I have the following a priori simple request in the RavenDb repository:

return _session
   .Query<StockKeepingUnit>()
   .Where(x => x.QuantityInStock < x.OrderLevel)
   .ToList()
   .GroupBy(x => x.BrandName);

To which RavenDb the exception is thrown in the Where clause: Could not understand expression: .Where(x => (x.QuantityInStock < x.OrderLevel))

I understand that the problem is that I cannot request a comparison of properties in the same object and call it .ToList()before it "bypasses" the problem, but it is extremely inefficient.

What would be the correct way to fulfill this request?

+4
source share
1 answer

You can do this in an index. This allows you to compute things once during indexing, and then during the query we can simply scan the index.

0
source

All Articles