How to replace only not sent null fields.
My Product Instance:
Product p1 = new Product(){ Name : "Apple", Money: 2 };
My Document:
{
"Id" : 1
"Name" : "Apppple",
"Money" : 3,
"Color" : "Red"
}
I runned this code:
var _filterDef = Builders<Product>.Filter.Eq(x => x.Id, 1);
ProductCollection.ReplaceOne(_filterDef, p1);
Result: Red named field is null...
{
"Id" : 1
"Name" : "Apple",
"Money" : 2,
"Color" : null
}
I Want to Result: Red named field is not null
{
"Id" : 1
"Name" : "Apple",
"Money" : 2,
"Color" : "Red"
}