在我的应用程序中,我使用以下模式调用数据库:
//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();
}
问题是 Operation1 和 Operation2 90% 的时间使用相同的数据库……但是当他们使用两个数据库时存在一些情况(错误)。如果事务变得分布式,我想得到一个异常。
如何检测事务是否提升为分布式事务?
谢谢,拉杜