Uredi

Deli z drugimi prek


Transaction Class

Definition

Represents a transaction.

public ref class Transaction : IDisposable, System::Runtime::Serialization::ISerializable
public class Transaction : IDisposable, System.Runtime.Serialization.ISerializable
[System.Serializable]
public class Transaction : IDisposable, System.Runtime.Serialization.ISerializable
type Transaction = class
    interface IDisposable
    interface ISerializable
[<System.Serializable>]
type Transaction = class
    interface IDisposable
    interface ISerializable
Public Class Transaction
Implements IDisposable, ISerializable
Inheritance
Transaction
Derived
Attributes
Implements

Remarks

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.

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. You can obtain the current transaction, if one is set, using the static Current property.

Properties

Current

Gets or sets the ambient transaction.

IsolationLevel

Gets the isolation level of the transaction.

PromoterType

Uniquely identifies the format of the byte[] returned by the Promote method when the transaction is promoted.

TransactionInformation

Retrieves additional information about a transaction.

Methods

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.

EnlistDurable(Guid, IEnlistmentNotification, EnlistmentOptions)

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, Guid)

Enlists a resource manager that has an internal transaction using a promotable single phase enlistment (PSPE).

EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification)

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)

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()

Gets the byte[] returned by the Promote method when the transaction is promoted.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

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

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)

Sets the distributed transaction identifier generated by the non-MSDTC promoter.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Operators

Equality(Transaction, Transaction)

Tests whether two specified Transaction instances are equivalent.

Inequality(Transaction, Transaction)

Returns a value that indicates whether two Transaction instances are not equal.

Events

TransactionCompleted

Indicates that the transaction is completed.

Explicit Interface Implementations

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

Gets a SerializationInfo with the data required to serialize this transaction.

Applies to

Thread Safety

This type is thread safe.

See also