I'm using the following code snippet to update an entity of one DataContext
// Mark the customer as updated.
context.UpdateObject(customerToChange);
// Send the update to the data service.
context.SaveChanges();
My problem however is, that I have multiple DataContexts.
For example, if I have DataContext A and B and save the changes also in this order.
Then the Behaviour right now is: If A succeeds and B fails, then it aborts. But the changes are already persisted to A!
Wished Behaviour: If A succeeds and B fails it should also rollback A.
So my idea would be something like this:
using(TransactionScope tran = new TransactionScope()) {
contextA.updateObject(objA);
contextB.updateObject(objB);
tran.Complete();
}
However, this seems not to be possible across multiple data contexts.
Do you have any ideas of how to implement this correctly with OData?