Given the comment from @neillunn and the lack of any documentation for this effect, it seems that the aggregation functions for cosmosdb are not supported through the mongo API. It seems like the intention is to use the cosmosdb Documentdb API SQL syntax for aggregates.
LINQ Syntax
var client = new DocumentClient(new Uri("https://<account>.documents.azure.com"),<password>); // issue query var documentUri = UriFactory.CreateDocumentCollectionUri("Prod", "retrieve"); var date = "20161011".Dump("Date"); var max = client.CreateDocumentQuery<ObservationDocument>(documentUri) .Where(i => i.Id == date) .SelectMany(i => i.observations) .Max(i => i.Duration);
SQL syntax
// explicit query var spec = new SqlQuerySpec("select value count(o.duration) from days d join o in d.observations where d._id = @id"); spec.Parameters = new Microsoft.Azure.Documents.SqlParameterCollection(); spec.Parameters.Add(new Microsoft.Azure.Documents.SqlParameter("@id", "20161010")); client.CreateDocumentQuery(UriFactory.CreateDocumentCollectionUri("Prod", "retrieve"), spec).Dump("As query");
Tedford
source share