Description
Consider the following aggregation defintion
DateTime now = DateTime.Now;
|
Collection.Aggregate().Group(x => x.AdapterShortKey, group => new { CountFoo = group.Count(x => x.DepartureDate < now) }); |
This code compiles and runs but does the wrong thing. Instead of counting the documents with the condition
x.DepartureDate < now
|
it counts all the documents.
The workaround is to write
group.Sum(x => x.DepartureDate < now ? 1 : 0)
|
which does the correct thing.