I'm trying to delete mongo document from particular collection in c#
how i'm trying now is
var document = collection.Find(_ => true).FirstOrDefault(); //get all the document
foreach (var item in (dynamic)document)
{
if (item.Timestamp >= "")
{
if ("Some Date" > Convert.ToDateTime(item.Timestamp))
{
collection.DeleteOne(item); //delete document one by one
}
}
}
here i'm trying get all the document and delete one by one but there will be lot of documents to delete it can affect to performance so is there any way to direct delete mongo documents instead of get and delete in c#