How does the Find () method in MongoDB.NET return the value of the specified field

  mongodb, question

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 ofMongoCursorInside, not outsideFindIn the method

public virtual MongoCursor SetFields(
 params string[] fields
 )

Like a series of other methods, it still returnsMongoCursor, so in fact you can do cascade operations on it, such as

collection.Find(...)
 .SetFields(...)
 .SetSortOrder(...)
 .SetSkip(...)
 .SetLimit(...)