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

后端 未结 5 1253
萌比男神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:44

    That's the way you do it. I'm sure you know this, but if you want to put it on one line you could combine it so you don't need to define a query variable:

    collection.Remove(Query.EQ("_id", a.Id));
    

提交回复
热议问题