在我的应用程序中,我使用以下模式来调用数据库:
//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%的时间使用相同的数据库...但是当它们使用两个数据库时存在一些情况(错误)。如果交易变得分布式,我想得到一个例外。
如何检测事务是否升级为分布式事务?
谢谢,拉杜
您还可以关注以下活动
TransactionManager.DistributedTransactionStarted 事件 http://msdn.microsoft.com/en-us/library/system.transactions.transactionmanager.distributedtransactionstarted.aspx
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)