How to remove one 'document' by 'ID' using the Official C# Driver for MongoDB?

后端 未结 5 1246
萌比男神i
萌比男神i 2020-12-10 01:09

Can someone please show me, if there is a better way to remove one document from MongoDB using the Official C# Driver than what I have below-

va         


        
5条回答
  •  春和景丽
    2020-12-10 01:28

    var filter = Builders.Filter.Eq("_id",ObjectId.Parse(id));
    var x = data.DeleteOne(filter);
    

    I am using this with the current version ( in 2019 ), and it works.

提交回复
热议问题