|
Hi Mohsen,
We are still debating save internally. Save is not an idempotent operation, which makes retrying failures difficult. As such, drivers decided not to implement save in their new APIs. However, we do recognize the need for it, so it may come back in the future with some slightly different semantics from what currently exists in 1.x.
For now, please review the documentation here: http://mongodb.github.io/mongo-csharp-driver/2.0/reference/driver/crud/writing/#update-and-replace. The ReplaceOneAsync method is what you would use as a replacement if you want to replace a document.
var entity = GetEntityToSave();
|
await collection.ReplaceOneAsync(x => x.Id == entity.Id, entity, new UpdateOptions { IsUpsert = true });
|
However, if you just created your entity, use InsertOneAsync.
I'm going to close this as Won't Fix for now. If we do implement something, another ticket will be open for the feature.
Thanks,
Craig
|