Reputation: 937
I have a similar issue addressed in this thread : Finding objects which contains at least one element from subset using RavenDB and LINQ, but the answer is not clear to me.
string[] Categories = new[] {"A", "B"};
foreach (var cat in Categories)
{
var currentTag = cat;
products = products.Where(p => p.Categories.Any(c =>c.Id == currentTag));
}
When debugging "Products", the result is an "AND" and not an "OR" between each where statement (e.g. ...where category=A AND category=B. How can you make the same, just with an OR operator?
I mean, give me all products, that at least have category A OR B.
Best Nima
Upvotes: 0
Views: 220
Reputation: 12849
You need to use In
operator.
string[] cats = new[] {"A", "B"};
var products = session.Query<Products>().Where(p => p.Categories.Any(c =>c.Id.In(cats)));
Upvotes: 2