public UnitOfWork(bool forceNewContext) { if (forceNewContext) { DataContextFactory.Clear(); } }
public void ExecuteSqlCommand(string cmd) { this.dbContext.Database.ExecuteSqlCommand(cmd); DataContextFactory.Clear(); var context = DataContextFactory.GetDataContext(); this.dbContext = context ?? throw new ArgumentNullException(nameof(context)); this.dbSet = this.dbContext.Set <TEntity>(); }
public void Commit(bool resetAfterCommit) { DataContextFactory.GetDataContext().SaveChanges(); if (resetAfterCommit) { DataContextFactory.Clear(); } }
protected Task ExecuteSqlCommand(string cmd) { return(Task.Run( () => { this.dbContext.Database.ExecuteSqlCommand(cmd); DataContextFactory.Clear(); var context = DataContextFactory.GetDataContext(); this.dbContext = context ?? throw new ArgumentNullException(nameof(context)); this.dbSet = this.dbContext.Set <TEntity>(); })); }
public void Undo() { DataContextFactory.Clear(); }