I'm using Aggregation to do a query and lookup. What's the most efficient way of returning both the results and count using one server call?
I've seen there is a way to do this using Facets, however, I'd like to do this using a Fluent expression with typed classes so I can abstract the logic into a generic extension method.
My current code looks something like this:
collection
.Aggregate ()
.Match (Builders<Order>.Filter...)
.Lookup (...)
.Project<Order> (Builders<Order>.Projection.Exclude ...)