/// <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(); } } }
protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { context.Dispose(); } } this.disposed = true; }
public void Dispose() { testDBContext.Dispose(); }
public void Cleanup() { Context.Dispose(); }
public void Dispose() { _context.Dispose(); }