Last active
August 28, 2017 13:57
-
-
Save dontpaniclabsgists/a6dcf3323f24bdb8cdb97c48aa4b7693 to your computer and use it in GitHub Desktop.
Cosmos2_7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<PageResult> Page(string token, int pageSize, string customerId) | |
{ | |
using (var client = new DocumentClient(new Uri(_endpoint), _key)) | |
{ | |
var link = UriFactory.CreateDocumentCollectionUri(_databaseId, CollectionId); | |
var querySetup = client.CreateDocumentQuery<Note>( | |
link, | |
new FeedOptions() | |
{ | |
MaxItemCount = pageSize, | |
RequestContinuation = token, | |
PartitionKey = new Microsoft.Azure.Documents.PartitionKey(customerId) | |
}); | |
var query = querySetup.AsDocumentQuery(); | |
var result = new PageResult() | |
{ HasMore = false }; | |
var list = new List<Note>(); | |
if (query.HasMoreResults) | |
{ | |
var note = await query.ExecuteNextAsync<Note>(); | |
result.Token = note.ResponseContinuation; | |
if (!string.IsNullOrWhiteSpace(result.Token)) | |
result.HasMore = true; | |
list.AddRange(note); | |
} | |
result.Notes = list.ToArray(); | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment