Skip to content

Instantly share code, notes, and snippets.

@dontpaniclabsgists
Created August 24, 2017 18:15
Show Gist options
  • Save dontpaniclabsgists/6991e816dc3f80aa1dd247452b946556 to your computer and use it in GitHub Desktop.
Save dontpaniclabsgists/6991e816dc3f80aa1dd247452b946556 to your computer and use it in GitHub Desktop.
Cosmos3_2
public int CountSql()
{
using (var client = new DocumentClient(new Uri(_endpoint), _key))
{
var link = UriFactory.CreateDocumentCollectionUri(_databaseId, CollectionId);
var count = client.CreateDocumentQuery<int>(
link,
"select value count(1) from notes",
new FeedOptions()
{
EnableCrossPartitionQuery = true
})
.AsEnumerable()
.First();
return count;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment