'CosmosDB Get Scalar Value in C# using CosmosClient
Does anyone know how to get a scalar value using the Microsoft.Azure.Comos.CosmosClient?
I have looked through the web and cannot find any examples.
All I want to do is to be able to execute a query like this
SELECT value COUNT(c._id)
FROM c
WHERE c._ts > @timestamp
There doesn't seem to get any function on either the CosmosClient or the Container classes to handle the type of query.
Thanks
Solution 1:[1]
var count = await _CosmosClient.GetCosmosContainer(CollectionName).
GetItemLinqQueryable<int>
().CountAsync();
return count;
That is what I do to return the count. However, I am still wondering if there is any looping going on behind the scene. I wish I just had a method in which I could return the count.
Can anyone explain what is difference between the solution that I have and the privous one count = (await qry.ReadNextAsync()).SingleOrDefault();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | redar ismail |
