Transaction Transaction Transaction Transaction Class

定义

表示事务。Represents a transaction.

public ref class Transaction : IDisposable, System::Runtime::Serialization::ISerializable
[System.Serializable]
public class Transaction : IDisposable, System.Runtime.Serialization.ISerializable
type Transaction = class
    interface IDisposable
    interface ISerializable
Public Class Transaction
Implements IDisposable, ISerializable
继承
TransactionTransactionTransactionTransaction
派生
属性
实现

注解

System.Transactions 命名空间提供基于 Transaction 类的显式编程模型和使用 TransactionScope 类的隐式编程模型,在后一种模型中,事务由该基础结构自动管理。The System.Transactions namespace provides both an explicit programming model based on the Transaction class, as well as an implicit programming model using the TransactionScope class, in which transactions are automatically managed by the infrastructure. 我们强烈建议你使用易于开发的隐式模型。We recommend highly that you use the easier implicit model for development. 若要开始使用,请参阅使用事务范围实现隐式事务主题。To get started, see the Implementing An Implicit Transaction Using Transaction Scope topic. 有关编写事务应用程序的详细信息,请参阅编写事务应用程序For more information on writing a transactional application, see Writing A Transactional Application.

Transaction类包含开发人员用来实现资源管理器的方法。The Transaction class contains methods used by developers implementing resource managers for enlistment. 它还提供了用于克隆事务和控制当前事务上下文的功能。It also provides functionalities for cloning a transaction and controlling the current transaction context. 如果已设置,则可以使用静态Current属性获取当前事务。You can obtain the current transaction, if one is set, using the static Current property.

属性

Current Current Current Current

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

IsolationLevel IsolationLevel IsolationLevel IsolationLevel

获取事务的隔离级别。Gets the isolation level of the transaction.

PromoterType PromoterType PromoterType PromoterType

对提升事务时由 Promote 方法返回的 byte [] 的格式进行唯一标识。Uniquely identifies the format of the byte[] returned by the Promote method when the transaction is promoted.

TransactionInformation TransactionInformation TransactionInformation TransactionInformation

检索有关某个事务的附加信息。Retrieves additional information about a transaction.

方法

BeginCommitInternal(AsyncCallback) BeginCommitInternal(AsyncCallback) BeginCommitInternal(AsyncCallback) BeginCommitInternal(AsyncCallback)
Clone() Clone() Clone() Clone()

创建事务的克隆。Creates a clone of the transaction.

DependentClone(DependentCloneOption) DependentClone(DependentCloneOption) DependentClone(DependentCloneOption) DependentClone(DependentCloneOption)

创建事务的依赖复本。Creates a dependent clone of the transaction.

Dispose() Dispose() Dispose() Dispose()

释放由该对象占用的资源。Releases the resources that are held by the object.

EndCommitInternal(IAsyncResult) EndCommitInternal(IAsyncResult) EndCommitInternal(IAsyncResult) EndCommitInternal(IAsyncResult)
EnlistDurable(Guid, IEnlistmentNotification, EnlistmentOptions) EnlistDurable(Guid, IEnlistmentNotification, EnlistmentOptions) EnlistDurable(Guid, IEnlistmentNotification, EnlistmentOptions) EnlistDurable(Guid, IEnlistmentNotification, EnlistmentOptions)

登记支持两阶段提交的持久资源管理器以参与事务。Enlists a durable resource manager that supports two phase commit to participate in a transaction.

EnlistDurable(Guid, ISinglePhaseNotification, EnlistmentOptions) EnlistDurable(Guid, ISinglePhaseNotification, EnlistmentOptions) EnlistDurable(Guid, ISinglePhaseNotification, EnlistmentOptions) EnlistDurable(Guid, ISinglePhaseNotification, EnlistmentOptions)

登记支持单阶段提交优化的持久资源管理器以参与事务。Enlists a durable resource manager that supports single phase commit optimization to participate in a transaction.

EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification) EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification) EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification) EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification)

对资源管理器进行登记,该资源管理器具有使用可提升的单阶段登记 (PSPE) 的内部事务。Enlists a resource manager that has an internal transaction using a promotable single phase enlistment (PSPE).

EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification, Guid) EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification, Guid) EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification, Guid) EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification, Guid)

对资源管理器进行登记,该资源管理器具有使用可提升的单阶段登记 (PSPE) 的内部事务。Enlists a resource manager that has an internal transaction using a promotable single phase enlistment (PSPE).

EnlistVolatile(IEnlistmentNotification, EnlistmentOptions) EnlistVolatile(IEnlistmentNotification, EnlistmentOptions) EnlistVolatile(IEnlistmentNotification, EnlistmentOptions) EnlistVolatile(IEnlistmentNotification, EnlistmentOptions)

登记在事务中支持两阶段提交参与的易失性资源管理器。Enlists a volatile resource manager that supports two phase commit to participate in a transaction.

EnlistVolatile(ISinglePhaseNotification, EnlistmentOptions) EnlistVolatile(ISinglePhaseNotification, EnlistmentOptions) EnlistVolatile(ISinglePhaseNotification, EnlistmentOptions) EnlistVolatile(ISinglePhaseNotification, EnlistmentOptions)

登记支持单阶段提交优化的可变资源管理器以参与事务。Enlists a volatile resource manager that supports single phase commit optimization to participate in a transaction.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定此事务和指定的对象是否相等。Determines whether this transaction and the specified object are equal.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

GetPromotedToken() GetPromotedToken() GetPromotedToken() GetPromotedToken()

获取提升事务时由 Promote 方法返回的 byte []Gets the byte[] returned by the Promote method when the transaction is promoted.

GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
PromoteAndEnlistDurable(Guid, IPromotableSinglePhaseNotification, ISinglePhaseNotification, EnlistmentOptions) PromoteAndEnlistDurable(Guid, IPromotableSinglePhaseNotification, ISinglePhaseNotification, EnlistmentOptions) PromoteAndEnlistDurable(Guid, IPromotableSinglePhaseNotification, ISinglePhaseNotification, EnlistmentOptions) PromoteAndEnlistDurable(Guid, IPromotableSinglePhaseNotification, ISinglePhaseNotification, EnlistmentOptions)

提升和登记支持两阶段提交的持久资源管理器以参与事务。Promotes and enlists a durable resource manager that supports two phase commit to participate in a transaction.

Rollback() Rollback() Rollback() Rollback()

回滚(中止)事务。Rolls back (aborts) the transaction.

Rollback(Exception) Rollback(Exception) Rollback(Exception) Rollback(Exception)

回滚(中止)事务。Rolls back (aborts) the transaction.

SetDistributedTransactionIdentifier(IPromotableSinglePhaseNotification, Guid) SetDistributedTransactionIdentifier(IPromotableSinglePhaseNotification, Guid) SetDistributedTransactionIdentifier(IPromotableSinglePhaseNotification, Guid) SetDistributedTransactionIdentifier(IPromotableSinglePhaseNotification, Guid)

设置由非 MSDTC 提升程序生成的分布式事务标识符。Sets the distributed transaction identifier generated by the non-MSDTC promoter.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

事件

TransactionCompleted TransactionCompleted TransactionCompleted TransactionCompleted

指示事务已完成。Indicates that the transaction is completed.

操作员

Equality(Transaction, Transaction) Equality(Transaction, Transaction) Equality(Transaction, Transaction) Equality(Transaction, Transaction)

测试两个指定的 Transaction 实例是否相等。Tests whether two specified Transaction instances are equivalent.

Inequality(Transaction, Transaction) Inequality(Transaction, Transaction) Inequality(Transaction, Transaction) Inequality(Transaction, Transaction)

返回一个值,该值指示两个 Transaction 实例是否不相等。Returns a value that indicates whether two Transaction instances are not equal.

显式界面实现

ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext)

获取含有序列化此事务所需要的数据的 SerializationInfoGets a SerializationInfo with the data required to serialize this transaction.

适用于

线程安全性

此类型是线程安全的。This type is thread safe.

另请参阅