So, I want to find documents in my Person collection which have particular items in StringValues (“sv”).
Hi Kevin,
You could try adding an extra mapping for StringValues to list the name the fields for k and v. For example:
public class Person
{
public string Name; //Mapped to "n"
public IEnumerable<StringValue> StringValues { get; set; } //Mapped to "sv"
}
public class StringValue
{
public string Key; //Mapped to 'k'
public string Value; //Mapped to 'v'
}
Then to query a document in Person collection where Key matching certain values you could do:
var query = collection.AsQueryable<Person>()
.Where(p => p.StringValues.Any(s => s.Key == "k1"));
The above snippet was tested in .Net v4.5.2 and mongocsharpdriver-2.2.3.
You may also find the examples in MongoDB C# driver LINQ useful.
Regards,
Wan.