I know that I can atomically update an existing Mongo document by setting specific fields. The following code will do it:
var update = MongoDB.Driver.Builders.Update.Set("InsideLegMeasurement", 32.4);
SafeModeResult result = personCollection.Update(query, update, UpdateFlags.Multi,SafeMode.True);
However, can I atomically update several fields by passing in a document that I want to 'merge' with the existing doc? Imagine I have a document as follows: {"favcolor":"red","favfood":"pasta"} and I want to update an existing doc with these values. I want to do this:
var update = MongoDB.Driver.Builders.Update.Merge({"favcolor":"red","favfood":"pasta"});
or even
var update = MongoDB.Driver.Builders.Update.Merge(myUpdateBsonDoc);
where myBsonDocument contains lots of fields which I don't want to have to 'unpack' from the doc that is to be merged with the original.
Is this possible somehow?
Thanks