Пример #1
0
 public UnitOfWork(bool forceNewContext)
 {
     if (forceNewContext)
     {
         DataContextFactory.Clear();
     }
 }
Пример #2
0
        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>();
        }
Пример #3
0
        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>();
     }));
 }
Пример #5
0
 public void Undo()
 {
     DataContextFactory.Clear();
 }