コード例 #1
0
ファイル: DbContext.cs プロジェクト: zmk523/CRL3
        internal CoreHelper.DBHelper GetDBHelper(DataAccessType accessType = DataAccessType.Default)
        {
            DBLocation.DataAccessType = accessType;
            var helper = SettingConfig.GetDbAccess(DBLocation);

            return(helper);
        }
コード例 #2
0
ファイル: AbsDBExtend.cs プロジェクト: datetime2/CRL3
        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));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: QueryExtension.cs プロジェクト: zmk523/CRL3
        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);
        }
コード例 #5
0
 /// <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);
 }
コード例 #6
0
ファイル: BaseProvider.cs プロジェクト: qaz734913414/CRL2
        /// <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);
        }
コード例 #7
0
        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);
        }