Ejemplo n.º 1
0
 public ShardingDbCreater()
 {
     //_srvComponent = service;
     _dbConfig = ShardingDbContext.GetDbConfig(typeof(T)) as ShardingDbTypeDefine <T>;
     if (_dbConfig == null)
     {
         throw new Exception($"未获取到{typeof(T).FullName}配置,请检查是否调用RegDb<T>进行注册!");
     }
 }
Ejemplo n.º 2
0
 public ShardAccessorBuilder()
 {
     ShardingDbContext.EnsureDbTypeReg(typeof(TDb));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 获取IQueryable实例AsNoTracking
 /// </summary>
 protected IQueryable <TEntity> Queryable(ShardingDbContext db)
 {
     return(db.Set <TEntity>().AsNoTracking());
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 创建DbCreater(主要用于子类调用,会确保Db的静态构造函数被调用-RegDb)
        /// </summary>
        protected ShardingDbCreater <T> DbCreater <T>() where T : ShardingDbContext
        {
            ShardingDbContext.EnsureDbTypeReg(typeof(T));

            return(GetComponent <ShardingDbCreater <T> >());
        }