In my application I use the following pattern for calling the DB:
//do a transaction
using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.Required))
{
OperationOnDb1();
//when we open the connection to the “other db” in this call, the transaction would become distributed
OperationOnDb2();
//transaction is now distributed
transaction.Complete();
}
The problem is that Operation1 and Operation2 90% of the time use the same db ... but there are cases (bugs) when they use two DBs. I want to get an exception if the transaction becomes distributed.
How can I detect if the transaction is promoted to a distributed transaction?
Thanks, Radu
You can also have a look at the following event