DocumentDB paging with many collections -


lets have 2 collections , there 10 documents in each collection. recommended way paging if want retrive max 15 documents?

when run code below 20 results. begins requesting first collection returnes 10 , second returns 10 should return 5 since maxitemcount 15.

        var batches = new list<ienumerable<t>>();         var feedoptions = new feedoptions         {             maxitemcount = 15         };          var docquery = client.createdocumentquery<t>(database.selflink, feedoptions)                  .where(predicate).asdocumentquery();                  {             var batch = await docquery.executenextasync<t>();             batches.add(batch);          } while (docquery.hasmoreresults);          var docs = batches.selectmany(b => b).take(maxitemcount.value);          return docs; 

maxitemcount controls number of results per page, not total results returned. reduce total number of results, change while clause check e.g., (docquery.hasmoreresults && batch.length <= maxitemcount.value).

hope helps.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -