Skip to content

Instantly share code, notes, and snippets.

@dontpaniclabsgists
Created September 1, 2017 16:08
Show Gist options
  • Save dontpaniclabsgists/307436cf9ce0ca27774255bd11fe5d25 to your computer and use it in GitHub Desktop.
Save dontpaniclabsgists/307436cf9ce0ca27774255bd11fe5d25 to your computer and use it in GitHub Desktop.
cosmos4_2
public async Task<Note[]> AllInPartition(string customerId)
{
using (var client = new DocumentClient(new Uri(_endpoint), _key))
{
var link = UriFactory.CreateDocumentCollectionUri(_databaseId, CollectionId);
var query = client.CreateDocumentQuery<Note>(
link,
new FeedOptions()
{
PartitionKey = new Microsoft.Azure.Documents.PartitionKey(customerId)
})
.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