How to construct IQueryable query using Linq when I just need count without reading all documents in Document-Db database?
问题 I need the number of documents stored in a collection in my Azure Cosmos Db database. How can I get the count using LINQ query on the IQueryable object? docDbClient.CreateDocumentQuery<TResult>().Count() If I do above, I am unable to follow it up with .AsDocumentQuery() method. 回答1: This is my async implementation (use Count, for the sync version): var count = await DocumentClient. CreateDocumentQuery<T>(CreateCollectionUri(), CreateFeedOptions()). Where(predicate). CountAsync(); where