The UpdateBuilder as currently implemented considers trying to set the same field to two different values an error (though I wish the exception thrown was more clear...).
It's not unreasonable to expect that calling Set for the same field twice would simply override the first one with the second one, but that's not how it currently works. If you feel it should work that way please file a JIRA ticket suggesting the change.
As a workaround, you could define an extension method on UpdateBuilder that behaves the way you want it to. It would probably look like this:
public static UpdateBuilder<TDocument> SetWithOverride<TDocument, TField>(this UpdateBuilder<TDocument> update, Expression<Func<TDocument, TField>> memberExpression, TField value)
{
var set = Update<TDocument>.Set(memberExpression, value).ToBsonDocument();
var combined = update.ToBsonDocument();
if (combined.Contains("$set"))
{
var element = set[0].AsBsonDocument.GetElement(0);
combined["$set"][element.Name] = element.Value;
}
else
{
combined.Merge(set);
}
return Update<TDocument>.Combine(combined.Elements.Select(e => new UpdateDocument(e)));
}
And here's some sample code showing it being used:
var update = Update<C>.Set(c => c.X, 1).Set(c => c.Y, 2);
update = update.SetWithOverride(c => c.Y, 3);