Jon
Jon

Reputation: 377

Find the intersection of two lists using the RavenDB 4 LINQ provider

How can you query RavenDB 4 to find documents which have a list of documents matching items from a input list?

The following used to work in RavenDB 3 but isn't supported in 4:

List<string> categories = new List<string>() { "C#", "java" });   
var jobs = _session.Query<Job, Job_Index>.Where(j => j.Categories.Any(c => c.In(categories)));

Upvotes: 1

Views: 137

Answers (1)

Judah Gabriel Himango
Judah Gabriel Himango

Reputation: 60011

I believe something like this should work:

using Raven.Client.Documents.Linq; // needed for .ContainsAny extension method

var categories = new List<string>() { "C#", "java" });   
var jobs = _session.Query<Job, Job_Index>
     .Where(j => j.Categories.ContainsAny(categories));

Upvotes: 2

Related Questions