Example:
var message = new SomeClassWithFieldCode();
//if code is null it will not update field, need to use BsonNull.Value in case if object value null
var update = Update.Set("Code", message.Code); // Code is null
mongoCollection.Update(Query.EQ("_id", message.Id), update);
I suppose driver should replace null with BsonNull.Value internally rather than set it manually on each update in case if some property value equals to null.
Thank you.