title: Pagination in Cosmos DB using Page Size and Page Number
body: <p>I am trying to return items from cosmosDB using <code>PageSize</code> and <code>PageNumber</code>. I know we can set the page size in <code>MaxItemCount</code>, but how do we put the page number in this function?</p>
  
  <p>Here's what I got so far:</p>
  
  <pre><code>  public async Task&lt;IEnumerable&lt;T&gt;&gt; RunSQLQueryAsync(string queryString, int pageSize, int pageNumber)
          {
              var feedOptions = new FeedOptions { MaxItemCount = pageSize, EnableCrossPartitionQuery = true };
              IQueryable&lt;T&gt; filter = _client.CreateDocumentQuery&lt;T&gt;(_collectionUri, queryString, feedOptions);
              IDocumentQuery&lt;T&gt; query = filter.AsDocumentQuery();
              var currentPageNumber = 0;
              var documentNumber = 0;
              List&lt;T&gt; results = new List&lt;T&gt;();
              while (query.HasMoreResults)
              {
                  foreach (T t in await query.ExecuteNextAsync())
                  {
                      results.Add(t);
                      documentNumber++;
                  }
                  currentPageNumber++;
                  return results;
  
              }
              return null;
          }
  </code></pre>