Transaction 類別

定義

表示交易。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
繼承
Transaction
衍生
屬性
實作

備註

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

取得或設定環境交易。Gets or sets the ambient transaction.

IsolationLevel

取得交易的隔離等級 (Isolation Level)。Gets the isolation level of the transaction.

PromoterType

可唯一識別 byte[] 的格式,其由 Promote 方法在交易升級時傳回。Uniquely identifies the format of the byte[] returned by the Promote method when the transaction is promoted.

TransactionInformation

擷取交易的其他資訊。Retrieves additional information about a transaction.

方法

BeginCommitInternal(AsyncCallback)
Clone()

建立交易的複製品 (Clone)。Creates a clone of the transaction.

DependentClone(DependentCloneOption)

建立交易的相依複製品。Creates a dependent clone of the transaction.

Dispose()

釋放該物件所持有的資源。Releases the resources that are held by the object.

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

登記支援兩階段交易認可 (Two-Phase Commit) 的長期資源管理員以參與交易。Enlists a durable resource manager that supports two phase commit to participate in a transaction.

EnlistDurable(Guid, ISinglePhaseNotification, EnlistmentOptions)

登記支援單一階段交易認可最佳化的長期資源管理員以參與交易。Enlists a durable resource manager that supports single phase commit optimization to participate in a transaction.

EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification)

使用可提升單一階段登記 (PSPE) 來登記具有內部交易的資源管理員。Enlists a resource manager that has an internal transaction using a promotable single phase enlistment (PSPE).

EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification, Guid)

使用可提升單一階段登記 (PSPE) 來登記具有內部交易的資源管理員。Enlists a resource manager that has an internal transaction using a promotable single phase enlistment (PSPE).

EnlistVolatile(IEnlistmentNotification, EnlistmentOptions)

登錄暫時性資源管理員,支援兩階段交易認可參與交易。Enlists a volatile resource manager that supports two phase commit to participate in a transaction.

EnlistVolatile(ISinglePhaseNotification, EnlistmentOptions)

登記支援單一階段交易認可最佳化的暫時性 (Volatile) 資源管理員以參與交易。Enlists a volatile resource manager that supports single phase commit optimization to participate in a transaction.

Equals(Object)

判斷這個交易和指定的物件是否相等。Determines whether this transaction and the specified object are equal.

GetHashCode()

傳回這個執行個體的雜湊碼。Returns the hash code for this instance.

GetPromotedToken()

當此交易升級時,取得 Promote 方法傳回的 byte[]Gets the byte[] returned by the Promote method when the transaction is promoted.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
PromoteAndEnlistDurable(Guid, IPromotableSinglePhaseNotification, ISinglePhaseNotification, EnlistmentOptions)

提升和登記支援兩階段交易認可 (Two-Phase Commit) 的長期資源管理員以參與異動。Promotes and enlists a durable resource manager that supports two phase commit to participate in a transaction.

Rollback()

復原 (中止) 交易。Rolls back (aborts) the transaction.

Rollback(Exception)

復原 (中止) 交易。Rolls back (aborts) the transaction.

SetDistributedTransactionIdentifier(IPromotableSinglePhaseNotification, Guid)

設定非 MSDTC Promoter 所產生的分散式異動識別碼。Sets the distributed transaction identifier generated by the non-MSDTC promoter.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

運算子

Equality(Transaction, Transaction)

測試兩個指定的 Transaction 執行個體是否相等。Tests whether two specified Transaction instances are equivalent.

Inequality(Transaction, Transaction)

傳回值,這個值表示兩個 Transaction 執行個體是否不相等。Returns a value that indicates whether two Transaction instances are not equal.

事件

TransactionCompleted

指出交易已完成。Indicates that the transaction is completed.

明確介面實作

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

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

適用於

執行緒安全性

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

另請參閱