title: Select and count in one query using Entity Framework?
body: <p>I am returning paged, filtered results from some of my REST routes. If I simplify my code, it goes something like this:</p>
  
  <pre><code>var query = db.SomeTable.Where(row =&gt; row.SomeProperty &gt; 42);
  
  return new Result {
      data = query.Skip(skip ?? 0).Take(take ?? 25).ToList(),
      count = query.Count() };
  </code></pre>
  
  <p>This works, but it produce two queries to a SQL Server database: one that fetches the data, second that counts them. How to do this in one query without resorting to a hand-written T-SQL query?</p>