Example #1
0
 /// <summary>
 /// 提交
 /// </summary>
 /// <param name="ctx"></param>
 public static void Commit(TranContext ctx)
 {
     ctx.Tran.Commit();
     ctx.Database.Connection.Close();
     ctx.Dispose(true);
     ctx.IsDisposed = true;
 }
Example #2
0
 /// <summary>
 /// 回滚
 /// </summary>
 /// <param name="ctx"></param>
 public static void Rollback(TranContext ctx)
 {
     ctx.Tran.Rollback();
     ctx.Database.Connection.Close();
     ctx.Dispose(true);
     ctx.IsDisposed = true;
 }
Example #3
0
 /// <summary>
 /// 开始事务
 /// </summary>
 /// <returns></returns>
 public static TranContext BeginTran()
 {
     TranContext ctx = new TranContext();
     ctx.IsDisposed = false;
     ctx.Database.Connection.Open();
     DbConnection con = ((IObjectContextAdapter)ctx).ObjectContext.Connection;
     ctx.Tran = con.BeginTransaction();
     return ctx;
 }