Skip to content

Instantly share code, notes, and snippets.

@dontpaniclabsgists
Last active August 28, 2017 13:53
Show Gist options
  • Save dontpaniclabsgists/b0ccda5c5002d9b84b8193280fa7deb2 to your computer and use it in GitHub Desktop.
Save dontpaniclabsgists/b0ccda5c5002d9b84b8193280fa7deb2 to your computer and use it in GitHub Desktop.
Cosmos2_1
public async Task<Note[]> All()
{
using (var client = new DocumentClient(new Uri(_endpoint), _key))
{
var link = UriFactory.CreateDocumentCollectionUri(_databaseId, CollectionId);
var query = client.CreateDocumentQuery<Note>(
link,
new FeedOptions()
{
EnableCrossPartitionQuery = true
})
.AsDocumentQuery();
var results = new List<Note>();
while (query.HasMoreResults)
{
results.AddRange(await query.ExecuteNextAsync<Note>());
}
return results.OrderBy(x => x.Id).ToArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment