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 database
select 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:
ProjectionThe method of
MongoCursorInside, not outside
FindIn the method
public 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 as
collection.Find(...) .SetFields(...) .SetSortOrder(...) .SetSkip(...) .SetLimit(...)