private async Task <List <TResult> > GetStaticDataAsync <TResult>(Func <IQueryable, Task <TResult> > query, IQueryable newSource = null)
        {
            newSource = newSource ?? _source;
            //获取读表要访问的表
            var physicTables = _virtualTable.RouteTo(new RouteConfig(newSource, null, null));
            // //临时上下文
            var contexts = new List <ShardingDbContext>(physicTables.Count);

            //获取所有的读表后缀
            try
            {
                var queryTasks = physicTables.Select(physicTable =>
                {
                    var shardingDbContext = _shardingDbContextProvider.CreateAloneShardingDbContext(physicTable.Tail);
                    contexts.Add(shardingDbContext);
                    var targetIQ          = shardingDbContext.GetIQueryable <T>();
                    var replacedNewSource = newSource.ReplaceQueryable(targetIQ);
                    return(query(replacedNewSource));
                });
                var result = (await Task.WhenAll(queryTasks)).ToList();
                return(result);
            }
            finally
            {
                //回收上下文
                contexts.ForEach(o => o.Dispose());
            }
        }
        public void Start()
        {
            var virtualTables = _virtualTableManager.GetAllVirtualTables();

            using var scope   = _serviceProvider.CreateScope();
            using var context = _shardingDbContextProvider.CreateAloneShardingDbContext(string.Empty);
            foreach (var virtualTable in virtualTables)
            {
                //获取ShardingEntity的实际表名
                var tableName = context.Model.FindEntityType(virtualTable.EntityType).GetTableName();
                virtualTable.SetOriginalTableName(tableName);
                CreateDateTable(virtualTable);
            }
        }