Exemplo n.º 1
0
 /// <summary>
 /// FP 函数 High order function
 /// </summary>
 /// <param name="actions"></param>
 public static void NeedTransactionBussinessLogic(Action[] actions, bool isSubmit)
 {
     using (var context = new TestDBContext())
     {
         try
         {
             foreach (var action in actions)
             {
                 if (action != null)
                 {
                     action();
                 }
             }
             if (isSubmit)
             {
                 context.SaveChanges(true);
             }
         }
         catch (Exception ex)
         {
             context.Database.RollbackTransaction();
         }
         finally
         {
             context.Dispose();
         }
     }
 }
Exemplo n.º 2
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
Exemplo n.º 3
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             context.Dispose();
         }
     }
     this.disposed = true;
 }
Exemplo n.º 4
0
 public void Dispose()
 {
     testDBContext.Dispose();
 }
 public void Cleanup()
 {
     Context.Dispose();
 }
Exemplo n.º 6
0
 public void Dispose()
 {
     _context.Dispose();
 }