title: How to replace old FindAs<Type> in new MongoDB C#?
body: <p>I should change version of MongoDB but I am a lot struggling and have a lot of questions. One of them is I had the method <a href="http://mongodb.github.io/mongo-csharp-driver/2.7/apidocs/html/M_MongoDB_Driver_MongoCollection_FindAs__1.htm" rel="nofollow noreferrer">FindAs&lt;&gt;()</a> but now it is part of legacy code and I should return that type that is already defined. I tried with method <em><strong>Find(query)</strong></em> and to somehow cast the return value, but it was unsuccessful. The part of code I want to change is the following:</p>
  <pre><code>GetCollection(GetCollectionName(collectionName), federatedDBKey)
                  .FindAs&lt;BsonDocument&gt;(query)
                  .SetFields(map.ElementName)
                  .AsQueryable()
                  .First();
  </code></pre>
  <p>This part <em>AsQueryable()</em> I replaced with:</p>
  <pre><code>IMongoCollectionExtensions.AsQueryable&lt;T&gt;(GetCollection(GetCollectionName(collectionName), federatedDBKey))
              .First();
  </code></pre>
  <p>But the other code I don't know how as <em><strong>SetFields</strong></em> also doesn't exist anymore...</p>