MongoDB and C# Find()

后端 未结 3 987
轻奢々
轻奢々 2020-12-03 12:21

I have the below code and I am new to mongodb, I need help in finding an specific element in the collection.

using MongoDB.Bson;
using MongoDB.Driver;
namesp         


        
3条回答
  •  醉酒成梦
    2020-12-03 12:55

    It also Varies according to the .Net framework version we are using. If we Use 2x driver it should look like :

    var list = await collection.Find(new BsonDocument()).ToListAsync();
    

    method 2

    await collection.Find(new BsonDocument()).ForEachAsync(X=>Console.WriteLine(X));
    

    Reference Example

提交回复
热议问题