I used MongoDB's Compass to created a pipeline that I exported to C#, however I am not sure how to use this (tool generates a BsonArray) in the actual code to perform an aggregation? This is a geoNear which isn't currently supported by LINQ, if that has any bearing.
I attempted to use this var result = collection.Aggregate(pipeline);
which some documentation suggested (pipeline - is that BsonArray object generated by Compass.
Example of what compass would create:
new BsonArray
{
new BsonDocument("$geoNear",
new BsonDocument
{
{ "near",
new BsonDocument
{
{ "type", "Point" },
{ "coordinates",
new BsonArray
{
-2.11,
52.55
} }
} },
{ "distanceField", "distanceField" },
{ "maxDistance", 5000 },
{ "spherical", true }
}),
new BsonDocument("$sort",
new BsonDocument("distanceField", -1))
};