|
While .NET driver has the aggregate pipeline builder, it is implemented via LINQ translation and Count operation (along with LongCount) is already supported via $sum accumulator, e.g. AggregateGroupTranslatorTests .Should_translate_count.
The $count accumulator operator itself is already supported in BSON form and can be specified in a BsonDocument-constructed ProjectionDefinition within group stage without additional changes to the driver, since this form of projection is passed to the server without transformation on the driver's side.
What could potentially be done is translating Count LINQ operator to "$count : {}" instead of "$sum : { 1 }", but that would create an unnecessary overhead of evaluating server version without providing advantages.
|