EntityTransaction 类

定义

指定 EntityCommand 的事务。Specifies the transaction for an EntityCommand.

public ref class EntityTransaction sealed : System::Data::Common::DbTransaction
public sealed class EntityTransaction : System.Data.Common.DbTransaction
type EntityTransaction = class
    inherit DbTransaction
Public NotInheritable Class EntityTransaction
Inherits DbTransaction
继承

注解

EntityTransaction 是从 EntityConnection 中获取的,可用于指定一个或多个 EntityCommand 对象。The EntityTransaction is obtained from the EntityConnection and specifies one or more EntityCommand objects. EntityTransaction 会包装基础数据提供程序的事务对象的事务。The EntityTransaction wraps the transaction of the underlying data provider's transaction object.

有关代码示例,请参阅管理连接和事务For code examples, see Managing Connections and Transactions.

属性

Connection

获取此 EntityConnectionEntityTransactionGets EntityConnection for this EntityTransaction.

DbConnection

在派生类中重写时,获取与事务关联的 DbConnection 对象。When overridden in a derived class, gets the DbConnection object associated with the transaction.

(继承自 DbTransaction)
IsolationLevel

获取此 EntityTransaction 的隔离级别。Gets the isolation level of this EntityTransaction.

SupportsSavepoints

获取一个值,该值指示此 DbTransaction 实例是否支持数据库保存点。Gets a value that indicates whether this DbTransaction instance supports database savepoints. 如果为 false,则 SaveAsync(String, CancellationToken)RollbackAsync(String, CancellationToken)ReleaseAsync(String, CancellationToken) 方法及其同步对应项应引发 NotSupportedExceptionIf false, the methods SaveAsync(String, CancellationToken), RollbackAsync(String, CancellationToken) and ReleaseAsync(String, CancellationToken) as well as their synchronous counterparts are expected to throw NotSupportedException.

(继承自 DbTransaction)

方法

Commit()

提交基础事务。Commits the underlying transaction.

CommitAsync(CancellationToken)

异步提交数据库事务。Asynchronously commits the database transaction.

(继承自 DbTransaction)
CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(继承自 MarshalByRefObject)
Dispose()

释放 DbTransaction 使用的非托管资源。Releases the unmanaged resources used by the DbTransaction.

(继承自 DbTransaction)
Dispose(Boolean)

释放由 DbTransaction 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the DbTransaction and optionally releases the managed resources.

(继承自 DbTransaction)
DisposeAsync()

异步处置事务对象。Asynchronously diposes the transaction object.

(继承自 DbTransaction)
Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(继承自 MarshalByRefObject)
GetType()

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

(继承自 Object)
InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(继承自 MarshalByRefObject)
MemberwiseClone()

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

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(继承自 MarshalByRefObject)
Release(String)

销毁先前在当前事务中定义的保存点。Destroys a savepoint previously defined in the current transaction. 这允许系统在事务结束之前回收一些资源。This allows the system to reclaim some resources before the transaction ends.

(继承自 DbTransaction)
ReleaseAsync(String, CancellationToken)

销毁先前在当前事务中定义的保存点。Destroys a savepoint previously defined in the current transaction. 这允许系统在事务结束之前回收一些资源。This allows the system to reclaim some resources before the transaction ends.

(继承自 DbTransaction)
Rollback()

回滚基础事务。Rolls back the underlying transaction.

Rollback(String)

回滚在建立指定保存点后执行的所有命令。Rolls back all commands that were executed after the specified savepoint was established.

(继承自 DbTransaction)
RollbackAsync(CancellationToken)

从挂起状态异步回滚事务。Asynchronously rolls back a transaction from a pending state.

(继承自 DbTransaction)
RollbackAsync(String, CancellationToken)

回滚在建立指定保存点后执行的所有命令。Rolls back all commands that were executed after the specified savepoint was established.

(继承自 DbTransaction)
Save(String)

在事务中创建保存点。Creates a savepoint in the transaction. 这样,在建立保存点后执行的所有命令都将被回滚,并将事务状态还原到保存点时的状态。This allows all commands that are executed after the savepoint was established to be rolled back, restoring the transaction state to what it was at the time of the savepoint.

(继承自 DbTransaction)
SaveAsync(String, CancellationToken)

在事务中创建保存点。Creates a savepoint in the transaction. 这样,在建立保存点后执行的所有命令都将被回滚,并将事务状态还原到保存点时的状态。This allows all commands that are executed after the savepoint was established to be rolled back, restoring the transaction state to what it was at the time of the savepoint.

(继承自 DbTransaction)
ToString()

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

(继承自 Object)

显式接口实现

IDbTransaction.Connection

获取与事务关联的 DbConnection 对象,或空引用(如果该事务不再有效)。Gets the DbConnection object associated with the transaction, or a null reference if the transaction is no longer valid.

(继承自 DbTransaction)

适用于

另请参阅