Skip to content

Instantly share code, notes, and snippets.

@dontpaniclabsgists
Created August 24, 2017 18:17
Show Gist options
  • Save dontpaniclabsgists/7cdd66f85ac528be3fff51affc372126 to your computer and use it in GitHub Desktop.
Save dontpaniclabsgists/7cdd66f85ac528be3fff51affc372126 to your computer and use it in GitHub Desktop.
cosmos3_4
public async Task<Note[]> AllSql()
{
using (var client = new DocumentClient(new Uri(_endpoint), _key))
{
var link = UriFactory.CreateDocumentCollectionUri(_databaseId, CollectionId);
var query = client.CreateDocumentQuery<Note>(link,
"select * from notes",
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