title: How to retrieve a total result count from the Sitecore 7 LINQ ContentSearch API?
body: <p>In Lucene.Net, it is possible to retrieve the total number of matched documents using the <code>TopDocs.TotalHits</code> property.</p>
  
  <p>This functionality <a href="https://github.com/sitecorian/SitecoreSearchContrib/blob/master/scSearchContrib.Searcher/QueryRunner.cs#L63" rel="nofollow">was exposed in the Advanced Database Crawler API</a> using an <code>out</code> parameter in the QueryRunner class.</p>
  
  <p><strong>What is the recommended way to retrieve the total result count using Sitecore 7's new LINQ API?</strong> It does not seem possible without enumerating the entire result set. Here is what I have so far:</p>
  
  <pre><code>var index = ContentSearchManager.GetIndex("sitecore_web_index");
  using (var context = index.CreateSearchContext())
  {
      var query = context.GetQueryable&lt;SearchResultItem&gt;()
                         .Where(item =&gt; item.Content == "banana");
  
      var totalResults = query.Count(); // Enumeration
      var topTenResults = query.Take(10); // Enumeration again? this can't be right?
  
      ...
  }
  </code></pre>