You can easily integrate transactions in a DomainService by overloading the Submit method on the service and creating the transaction scope there:
1: using (var tx = new TransactionScope( TransactionScopeOption.Required,
2: new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }))
3: {
4: base.Submit(changeSet);
5: tx.Complete();
6: }
The Insert*, Update* and Delete* methods will be called one by one inside the given scope.
Have fun,
1 comment:
Hello,
Please allow me to add a short note to your short note :)
That is only needed when your domain service derives directly from the DomainService class.
If you're using EntityFramework you can derive from LinqToEntitiesDomainService and the transaction will be handled automatically by EF's ObjectContext.
Best regards,
MF.
Post a Comment