hello how i can atomic do action like: insert if not exists without update if exists for object with example 100 fields ?
I try
-
Replace
method with upsert , but it update fields if exists. - I found solution like update+$setOnInsert but this method require field (not ready object) and i take 50 line code
example on insert i need only 50 fields,
var newObject = new
{
a = 'asdas',
b = 'fdsd',
c = 'ngasdas',
}
Update ( findById
Builders<C>.Update.SetOnInsert(c => c.a, newObject.a);
Builders<C>.Update.SetOnInsert(c => c.b, newObject.b);
Builders<C>.Update.SetOnInsert(c => c.c, newObject.c);
........... more 47 lines....
,upsert = true)
is there a better solution than this?