internal CoreHelper.DBHelper GetDBHelper(DataAccessType accessType = DataAccessType.Default) { DBLocation.DataAccessType = accessType; var helper = SettingConfig.GetDbAccess(DBLocation); return(helper); }
internal AbsDBExtend copyDBExtend() { var helper = SettingConfig.GetDbAccess(dbContext.DBLocation); var dbContext2 = new DbContext(helper, dbContext.DBLocation); dbContext2.ShardingMainDataIndex = dbContext.ShardingMainDataIndex; dbContext2.UseSharding = dbContext.UseSharding; return(DBExtendFactory.CreateDBExtend(dbContext2)); }
internal override DbContext GetDbContext() { if (SettingConfig.GetDbAccess == null) { throw new Exception("请配置CRL数据访问对象,实现CRL.SettingConfig.GetDbAccess"); } var helper = SettingConfig.GetDbAccess(dbLocation); var dbContext = new DbContext(helper, dbLocation); return(dbContext); }
static DbContext getDbContext <T>() { var dbLocation = new CRL.DBLocation() { DataAccessType = DataAccessType.Default, ManageType = typeof(T) }; var helper = SettingConfig.GetDbAccess(dbLocation); var dbContext = new DbContext(helper, dbLocation); return(dbContext); }
/// <summary> /// 仅用来检查表结构 /// </summary> /// <returns></returns> DBExtend GetBackgroundDBExtend() { if (backgroundDBExtend == null) { var helper = SettingConfig.GetDbAccess(dbContext.DBLocation); var dbContext2 = new DbContext(helper, dbContext.DBLocation); dbContext2.ShardingMainDataIndex = dbContext.ShardingMainDataIndex; dbContext2.UseSharding = dbContext.UseSharding; backgroundDBExtend = new DBExtend(dbContext2); } return(backgroundDBExtend); }
/// <summary> /// 数据访问对象[基本方法] /// 按指定的类型 /// </summary> /// <param name="type"></param> /// <returns></returns> protected DBExtend GetDbHelper(Type type) { if (SettingConfig.GetDbAccess == null) { throw new Exception("请配置CRL数据访问对象,实现CRL.SettingConfig.GetDbAccess"); } CoreHelper.DBHelper helper = SettingConfig.GetDbAccess(type); var db = new DBExtend(helper); db.OnUpdateNotifyCacheServer = OnUpdateNotifyCacheServer; TypeCache.SetDBAdapterCache(typeof(TModel), db._DBAdapter); return(db); }
internal override DbContext GetDbContext() { DbContext dbContext = null; ////cache = false; //string contextName = "DbContext." + GetType().Name;//同一线程调用只创建一次 //var _BeginTransContext = CallContext.GetData<bool>(Base.CRLContextName); //if (_BeginTransContext)//对于数据库事务,只创建一个上下文 //{ // contextName = "TransDbContext"; //} //if (cache) //{ // dbContext = CallContext.GetData<DbContext>(contextName); //} //if (dbContext != null) //{ // return dbContext; //} if (SettingConfig.GetDbAccess == null) { throw new CRLException("请配置CRL数据访问对象,实现CRL.SettingConfig.GetDbAccess"); } var helper = SettingConfig.GetDbAccess(dbLocation); //helper.Name = Guid.NewGuid().ToString(); dbContext = new DbContext(helper, dbLocation); //if (cache) //{ // dbContext.Name = contextName; // var allKey = "AllDbContext"; // var allList = Base.GetCallDBContext(); // CallContext.SetData(contextName, dbContext); // allList.Add(contextName); // CallContext.SetData(allKey, allList); //} return(dbContext); }