コード例 #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();
            }
        }
コード例 #4
0
 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();
 }