FindAll in MongoDB .NET Driver 2.0

前端 未结 3 665
既然无缘
既然无缘 2021-02-19 07:50

I want to query my MongoDB collection without any filter with MongoDB .NET Driver 2.0 but I didn\'t find a way. I have the following workaround but it looks weird :D

<         


        
3条回答
  •  情书的邮戳
    2021-02-19 08:41

    FindAll() is the part of MongoDB 1x series driver. to get the same functionality in 2x series driver use find() with empty BSON Document.

    var list = await collection.Find(new BsonDocument()).ToListAsync();
    foreach (var dox in list)
    {
        Console.WriteLine(dox);
    }
    

    Reference

提交回复
热议问题