DbContextTransaction 类

[本页针对的是实体框架版本 6。最新版本以“实体框架”NuGet 包的形式提供。有关实体框架的更多信息,请参见 msdn.com/data/ef。]

包装对基础存储连接的事务对象的访问并确保实体框架在该事务的上下文内对数据库执行命令。 通过对 DbContextDatabase 对象调用 BeginTransaction() 来检索此类的实例。

继承层次结构

System.Object
  System.Data.Entity.DbContextTransaction

命名空间:  System.Data.Entity
程序集:  EntityFramework(在 EntityFramework.dll 中)

语法

声明
Public Class DbContextTransaction _
    Implements IDisposable
用法
Dim instance As DbContextTransaction
public class DbContextTransaction : IDisposable
public ref class DbContextTransaction : IDisposable
type DbContextTransaction =  
    class 
        interface IDisposable 
    end
public class DbContextTransaction implements IDisposable

DbContextTransaction 类型公开以下成员。

属性

  名称 描述
公共属性 UnderlyingTransaction 获取基础化此上下文事务的数据库(存储)事务。

顶部

方法

  名称 描述
公共方法 Commit 提交基础存储事务。
公共方法 Dispose() 清除此事务对象并确保实体框架不再使用该事务。
受保护的方法 Dispose(Boolean) 释放此事务对象占用的资源。
公共方法 Equals 确定此实例是否与指定对象相同。 (重写 Object.Equals(Object)。)
受保护的方法 Finalize (继承自 Object。)
公共方法 GetHashCode 返回当前实例的哈希代码。 (重写 Object.GetHashCode()。)
公共方法 GetType 获取与此实例关联的基础类型。
受保护的方法 MemberwiseClone (继承自 Object。)
公共方法 Rollback 回滚基础存储事务。
公共方法 ToString 返回此实例的字符串表示形式。 (重写 Object.ToString()。)

顶部

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

请参阅

参考

System.Data.Entity 命名空间