Search code examples
.netnosqlazure-cosmosdb

How to execute GetItemLinqQueryable returning int asynchronously?


Is it possible to execute asynchronously such query, which returns an int?

Example and my use case:

var place = container.GetItemLinqQueryable<GuildModel>()
            .Where(m => m.Score < guild.Resource.Score)
            .Count()

If I understand this correctly, I should use ToFeedIterator, like I did with queries returning documents, but here Count() returns only int. I can use allowSynchronousQueryExecution but it seems fishy. :)


Solution

  • Microsoft.Azure.Cosmos.Linq contains an CountAsync() which you can use in combination with GetItemLinqQueryable<T>().