.net检测分布式事务

标签 .net transactions transactionscope distributed-transactions

在我的应用程序中,我使用以下模式调用数据库:

    //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 Event

关于.net检测分布式事务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4274887/

相关文章:

c# - 无法在.NET4 中加密/解密 SQLite 数据库

.net - 未触发 Oracle 登录触发器

c# - 使用 EF 在不同上下文之间进行事务

.net - 如何防止预期的异常破坏调试测试运行?

c# - Console.Write 会失败吗?

c# - .NET TransactionScopeOption.Suppress 的 T-SQL 等价物

Firebase 如何以原子方式防止重复条目

java - TransactionEventHandler 在 Node.setProperty() 上给出 javax.transaction.SystemException

c# - 如何知道代码是否在 TransactionScope 内?

c# - 交易范围超时 10 分钟