如何使用c#中的集合名称删除Mongodb集合

raj*_*esh 6 mongodb c#-4.0

我在c#中使用mongo在数据库中创建了一个集合.我能够使用ID而不是集合删除集合中的内容.Pls帮助我如何使用c#删除集合

Joh*_*yHK 14

没有多少,只需要调用Drop()集合:

var test = db.GetCollection("test");
test.Drop();
Run Code Online (Sandbox Code Playgroud)

更新:新的C#API方法是:

db.DropCollection("test");
Run Code Online (Sandbox Code Playgroud)