For some reason I cannot get paging properly working for Azure DocumentDB
Here is a code snippet
var finalResults = new List<MyResult>();
// Here I am setting max page size to be 10
var options = new FeedOptions { MaxItemCount = 10 };
var query = client.CreateDocumentQuery<MyResultItem>(collection.SelfLink, options)
.SelectMany(r => r.Results)
.Where(r => r.Result > 75)
.Select(r => r)
.AsDocumentQuery();
// it only works 1 iteration and next iteration I always get HasMoreResults = false
// if I set MaxItemCount = 20, then I get 20 only
while (query.HasMoreResults)
{
var pagedResults = query.ExecuteNextAsync<MyResult>().Result;
foreach (var pagedResult in pagedResults)
{
finalResults.Add(pagedResult);
}
}
No matter what value I set for MaxItemCount, it will only get that many items and will not get the next batch, so I get query.HasMoreResults always returning false on the second iteration. I cannot find where the problem is
Update:
Json structure is as follows:
.NET object name MyResultItem
{
Id: "xxxxxxxxxxxxxxxxxxxxx",
Name: "xxxxxxxxxxxxxxx",
Results: [
{ Id: 1, Result: 123 },
{ Id: 2, Result: 40 },
{ Id: 3, Result: 75 }
]
}
I am trying to get a flat list of "Results" where Result > 75