you can do this by creating an index for your query
public class GetOrdersByProductIndex: AbstractIndexCreationTask<Order,GetOrdersByProductIndex.Result> { public class Result { public string Product {get; set;} } public GetOrdersByProductIndex() { Map = orders => from order in orders select new { Product = order.LineItems.Select(x => x.Product) }; } }
Now you can use this index to receive orders. Your request should look like this:
using(IDocumentSession session = docStore.OpenSession()) { var orders = session.Query<GetOrdersByProductIndex.Result,GetOrdersByProductIndex> .Where(x=>x.Product != "Apple") .As<Order>() .ToList() }
Please note that by default it will only return 128 records (due to the restriction set by ravendb), if your query results contain more than 128 records, you should use the Take(recordsNeeded) function to retrieve the data.
source share