예제 #1
0
        /// <summary>
        /// 获取ShardingRepository
        /// </summary>
        /// <param name="absDbName">抽象数据库</param>
        /// <returns>ShardingRepository</returns>
        public static IShardingRepository GetShardingRepository(string absDbName = ShardingConfig.DefaultAbsDbName)
        {
            ShardingConfig.CheckInit();

            var dbType = ShardingConfig.ConfigProvider.GetAbsDbType(absDbName);

            return(new ShardingRepository(GetRepository(string.Empty, dbType), absDbName));
        }
예제 #2
0
        /// <summary>
        /// 获取ShardingDbAccessor
        /// </summary>
        /// <param name="absDbName">抽象数据库</param>
        /// <returns>ShardingDbAccessor</returns>
        public static IShardingDbAccessor GetShardingDbAccessor(string absDbName = ShardingConfig.DefaultAbsDbName)
        {
            ShardingConfig.CheckInit();

            var dbType = ShardingConfig.ConfigProvider.GetAbsDbType(absDbName);

            return(new ShardingDbAccessor(GetDbAccessor(string.Empty, dbType), absDbName));
        }
예제 #3
0
        /// <summary>
        /// 转为Sharding
        /// </summary>
        /// <typeparam name="T">实体泛型</typeparam>
        /// <param name="source">数据源</param>
        /// <param name="absDbName">抽象数据库</param>
        /// <returns>IShardingQueryable</returns>
        public static IShardingQueryable <T> ToSharding <T>(this IQueryable <T> source, string absDbName = ShardingConfig.DefaultAbsDbName) where T : class, new()
        {
            ShardingConfig.CheckInit();

            return(new ShardingQueryable <T>(source, DbFactory.GetShardingRepository(absDbName) as ShardingRepository, absDbName));
        }