Skip to content

Commit

Permalink
Update sample to read all the documents.
Browse files Browse the repository at this point in the history
Updated ReadDocumentFeedAsync to use the continuation token to ensure all the documents are read.
  • Loading branch information
j82w authored Mar 7, 2019
1 parent edf4d06 commit 57ec591
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions samples/code-samples/DocumentManagement/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,18 @@ private static async Task ReadDocumentAsync()
//******************************************************************************************************************
Console.WriteLine("\n1.3 - Reading all documents in a collection");

foreach (Document document in await client.ReadDocumentFeedAsync(
UriFactory.CreateDocumentCollectionUri(databaseName, collectionName),
new FeedOptions { MaxItemCount = 10 }))
string continuationToken = null;
do
{
Console.WriteLine(document);
}
var feed = await client.ReadDocumentFeedAsync(
UriFactory.CreateDocumentCollectionUri(databaseName, collectionName),
new FeedOptions { MaxItemCount = 10, RequestContinuation = continuationToken });
continuationToken = feed.ResponseContinuation;
foreach (Document document in feed)
{
Console.WriteLine(document);
}
} while (continuationToken != null);
}

private static SalesOrder QueryDocuments()
Expand Down

0 comments on commit 57ec591

Please sign in to comment.