编程语言
首页 > 编程语言> > c# – 有没有办法检查代码是否在TransactionScope中执行?

c# – 有没有办法检查代码是否在TransactionScope中执行?

作者:互联网

有没有办法检查代码是否在TransactionScope中执行?

就像是:

if(TransactionScope.Started|Enabled){...}

解决方法:

是有方法(直接从TransactionScope的MSDN文档复制):

The ambient transaction is the
transaction your code executes in. You
can obtain a reference to the ambient
transaction by calling the static
Current property of the Transaction
class.

那么看一下Transaction.Current.

标签:c,net,transactionscope
来源: https://codeday.me/bug/20190717/1484227.html