Skip to main content
added [nosql] to 5860 questions - Shog9 (Id=811)
Link
edited tags
Link
Neil Lunn
  • 151k
  • 36
  • 354
  • 324
edited tags
Source Link
abatishchev
  • 100.2k
  • 88
  • 301
  • 442

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

UPDATEUpdate:

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

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

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

added Josn structure
Source Link
fenix2222
  • 4.7k
  • 4
  • 37
  • 56
Loading
edited title
Link
fenix2222
  • 4.7k
  • 4
  • 37
  • 56
Loading
Source Link
fenix2222
  • 4.7k
  • 4
  • 37
  • 56
Loading