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 類別的明確程式撰寫模型 (Programming Model),以及使用 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

可唯一識別 byte[] 的格式,其由 Promote 方法在交易升級時傳回。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 的淺層複本 (Shallow Copy)。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 Promoter 所產生的分散式異動識別碼。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)

取得SerializationInfo序列化這個交易所所需的資料。Gets a SerializationInfo with the data required to serialize this transaction.

適用於

執行緒安全性

此型別具備執行緒安全。This type is thread safe.

另請參閱