Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Delete a Mongodb collection using collection name in c# [closed]

Tags:

mongodb

c#-4.0

I have created a collection in a database using mongo in c# . Iam able to delete the content in the collection using ID but not the collection .Pls help me how to drop a collection using c#

like image 678
rajesh Avatar asked Dec 20 '13 04:12

rajesh


1 Answers

There's not much to it, just call Drop() on the collection:

var test = db.GetCollection("test");
test.Drop();

Update: The new C# API way of doing this is:

db.DropCollection("test");
like image 198
JohnnyHK Avatar answered Sep 18 '22 07:09

JohnnyHK