title: Getting an item count with MongoDB C# driver query builder
body: <p>Using the c# driver for MongoDB I can easily construct a query against which I can then add SetSkip() and SetLimit() parameters to constrict the result set to a certain size. </p>
  
  <p>However I'd like to be able to know what item count of the query would be before applying Skip and Take <em>without</em> executing the query and loading the entire result set (which could be huge) into memory.</p>
  
  <p>It looks like I can do this with MongoDB directly through the shell by using the count() command. e.g.:</p>
  
  <pre><code> db.item.find( { "FieldToMatch" : "ValueToMatch" } ).count()
  </code></pre>
  
  <p>Which just returns an integer and that's exactly what I want. But I can't see a way in the documentation of doing this through the C# driver. Is it possible?</p>
  
  <p>(It should be noted that we're already using the query builder extensively, so ideally I'd much rather do this through the query builder than start issuing commands down to the shell through the driver, if that's possible. But if that's the only solution then an example would be helpful, thanks.)</p>
  
  <p>Cheers,
  Matt</p>