title: MongoDB C# Select specific columns
body: <p>I know that MongoDb C# driver doesn't support projections so I searched a little bit and I found that many people uses a mongoCursor to perform such queries, I'm trying to select only specific fields and my code is the following:</p>
  
  <pre><code>public T GetSingle&lt;T&gt;(Expression&lt;Func&lt;T, bool&gt;&gt; criteria,params Expression&lt;Func&lt;T, object&gt;&gt;[] fields) where T : class
  {
      Collection = GetCollection&lt;T&gt;();
      return Collection.FindAs&lt;T&gt;(Query&lt;T&gt;.Where(criteria)).SetFields(Fields&lt;T&gt;.Include(fields)).SetLimit(1).SingleOrDefault();
  } 
  </code></pre>
  
  <p>I got and custom repository for users on top of that:</p>
  
  <pre><code>public User GetByEmail(string mail, params Expression&lt;Func&lt;User, object&gt;&gt;[] fields)
  {
      return GetSingle&lt;User&gt;(x=&gt;x.Email==mail,fields);
  }
  </code></pre>
  
  <p>this is the usage:</p>
  
  <pre><code>_repository.GetByEmail(email, x=&gt;x.Id,x=&gt;x.DisplayName,x=&gt;x.ProfilePicture)
  </code></pre>
  
  <p>but I'm getting the fields included in the parameter but also all the Enums,dates and Boolean values that are part of the class User, the values that are string and not included in the field list are null so that's fine</p>
  
  <p><img src="https://i.stack.imgur.com/87Kro.jpg" alt="enter image description here"></p>
  
  <p><strong><em>what can I do to avoid that?</em></strong></p>