Transaction.Current 属性


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

 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. 如果使用中TransactionScope InvalidOperationException的此属性更改环境事务,则在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.