2

How can i do this from c# mongoDb drivers.

sql query :SELECT a,b FROM users

mondb javascript query : db.users.find({}, {a:1,b:1})

1

1 Answer 1

3

How about this:

 var database = MongoDatabase.Create(connectionString);
 var userCollection = database.GetCollection<Exercise>("users");
 var users = userCollection.Find().SetFields("a", "b");

If I understand your question correctly .SetFields does what you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.