Transaction.Current Transaction.Current Transaction.Current Transaction.Current Property

定义

获取或设置环境事务。Gets or sets the ambient transaction.

public:
 static property System::Transactions::Transaction ^ Current { System::Transactions::Transaction ^ get(); void set(System::Transactions::Transaction ^ value); };
public static System.Transactions.Transaction Current { get; set; }
member this.Current : System.Transactions.Transaction with get, set
Public Shared Property Current As Transaction

属性值

描述当前事务的 TransactionA Transaction that describes the current transaction.

注解

有关环境事务的详细信息,请参阅"管理事务流使用 TransactionScopeOption"部分实现隐式事务使用事务范围主题。For more information on ambient transactions, please see the "Managing transaction flow using TransactionScopeOption" section of the Implementing an Implicit Transaction using Transaction Scope topic.

尽管您可以设置使用此属性的环境事务,则应使用TransactionScope对象操作的环境事务,只要有可能。Although you can set the ambient transaction using this property, you should use the TransactionScope object to manipulate the ambient transaction whenever possible.

此属性是静态的线程。This property is thread static. 如果更改使用此属性内的环境事务TransactionScopeInvalidOperationException时,将引发Dispose调用时,并还原以前的环境事务值。If you change the ambient transaction using this property inside a TransactionScope an InvalidOperationException is thrown when Dispose is called, and the previous ambient transaction value is restored.

适用于