title: Getting total result count and allowing pagination in the same query with MongoDB
body: <p>I have my query set up like so to allow for pagination. While this works, I have to basically run the same query twice to get the total matching results for the query AND allow for pagination. Is there any way to combine this into a single query?</p>
  
  <pre><code>public SearchResult GetResults()
  {
      //query is built elsewhere
      var totalResults = (from i in Collection.Find(query)
          select i).Count();
  
      var results = (from i in Collection.Find(query)
          select i)
          .Skip(recordsToSkip)
          .Take(recordsToTake)
          .ToList();
  
      //SearchResult is defined elsewhere
      return new SearchResult
      {
          Results = results,
          TotalResults = totalResults
      };
  }
  </code></pre>