The ASP.NET MV C5 used wants to filter and then read the specified data from mongoDB according to the conditions, similar to the relational databaseselect fields1,fields form table where name='123'
How should mongoDB operate in. NET write a method to return specific fields? Look at the documents and search can’t find a suitable solution, help you
Although sometimes the document is not perfect, your question should be able to find the answer directly from the document, but you may not find the right place.
Select driver version:
https://api.mongodb.com/csharp/
ProjectionThe method ofMongoCursor
Inside, not outsideFind
In the methodpublic virtual MongoCursor SetFields( params string[] fields )
Like a series of other methods, it still returns
MongoCursor
, so in fact you can do cascade operations on it, such ascollection.Find(...) .SetFields(...) .SetSortOrder(...) .SetSkip(...) .SetLimit(...)