Hi I’m using TransactionScope on several places in my app. Like:
using (var scope = new TransactionScope())
{
ToDo1();
ToDo2();
scope.Complete();
}
I would like to have a possibility to disable all my TransactionScopes in one place.
I imagining something like MyTransactionScope class, where I can define if I want to use it or not.
Can you give me a hint how to achieve it?
Thank you.
I’ve done this. You can’t inherit
TransactionScopebecause it is sealed. Instead you contain the class inside yourMyTransactionScopeclass. Also implementIDisposableso you can call it under using construct. And expose.Complete()and other related methods. These methods will internally call the inner contained object.