title: mongodb c# select specific field
body: <p>Need some help creating a <em>generic</em> method for selecting fields by their name.</p>
  
  <p>something like this:</p>
  
  <pre><code>T GetDocField&lt;T&gt;(string doc_Id, string fieldName)
  </code></pre>
  
  <p>The best I got is using <strong>projection</strong> which gives me the doc with only the wanted field seted:</p>
  
  <pre><code> public T GetDocField&lt;T&gt;(string Doc_Id, string fieldName)
   {
      var value = DocCollection.Find(d =&gt; d.Id == Doc_Id)
                 .Project&lt;T&gt;(Builders&lt;Doc&gt;.Projection
                 .Include(new StringFieldDefinition&lt;Doc&gt;
                 (fieldName))).FirstOrDefaultAsync().Result;
  </code></pre>
  
  <p><em>note:</em>
  I'm using the new c# driver <strong>(2.0)</strong></p>
  
  <p>Thanks!!</p>