Given this schema:
> db.foo.find().pretty() { "_id" : 1, "bars" : [ { "x" : 1, "y" : 2 }, { "x" : 2, "y" : 3 }, { "x" : 1, "y" : 4 } ] }
and these classes:
private class Foo { public int Id; public List<Bars> Bars; } private class UnwoundFoo { public int Id; [BsonElement("Bars")] public Bar Bar; } private class Bar { [BsonElement("x")] public int X; [BsonElement("y")] public int Y; }
The following aggregation query results in a NRE:
var list = await col.Aggregate() .Unwind<Foo, UnwoundFoo>(x => x.Bars) .Match(x => x.Bar.X == 1) .Project(x => new { X = x.Bar.X, Y = x.Bar.Y }) .ToListAsync();