I have an object similar to the one below in C#. I would like to find matching person objects that contain an item matching a provided type and that item's sourceId is also present in an array of provided sourceIds:
Person: {
id: 1,
items: [
{
type: "one",
sourceId: 2
},
{
type: "two"
sourceId: 3
}
]
}
So far I have come up with this:
var filter = Builders<Person>.Filter.In(p => p.items.Where(i => i.type == "one").FirstOrDefault().sourceId, providedIds);
var results = PersonCollection.FindAsync(filter);
When I run, I get this error:
Unable to determine the serialization information for p => p.items.Where(i => (i.type == "one")).FirstOrDefault().sourceId
From what I can have been able to find, it seems that the Mongo driver doesn't understand FirstOrDefault (or perhaps Where as well). How might I accomplish this query?