Esempio n. 1
0
 protected virtual void Dispose(bool disposing)
 {
     if (!disposedValue)
     {
         if (disposing)
         {
             _db?.Dispose();
         }
         _transaction = null;
         DbModelFactory.RemoveObserver(this);
         disposedValue = true;
     }
 }
Esempio n. 2
0
        public void RefreshDb()
        {
            //重用DbConnection,使用底层相同的DbConnection,支持Model持热更新
            DbConnection con = null;

            if (_transaction != null)
            {
                con = _transaction.Connection;
            }
            else
            {
                con = _db?.Database?.GetDbConnection() ?? DbProviderFactoryHelper.GetDbConnection(_conString, _dbType);
            }

            var dBCompiledModel = DbModelFactory.GetDbCompiledModel(_conString, _dbType);

            _db = new DbContextBase(_dbType, con, dBCompiledModel);
            _db.Database.UseTransaction(_transaction);
            disposedValue = false;
        }
Esempio n. 3
0
        private Type CheckModel(Type type)
        {
            Type model = DbModelFactory.GetModel(type);

            return(model);
        }