public async Task <IStreamMergeAsyncEnumerator <T> > GetStreamEnumerator() { var enumeratorTasks = _mergeContext.RouteResults.Select(routeResult => { return(Task.Run(async() => { var shardingDbContext = _mergeContext.CreateDbContext(); _parallelDbContexts.Add(shardingDbContext); var newQueryable = (IQueryable <T>)_mergeContext.GetReWriteQueryable().ReplaceDbContextQueryable(shardingDbContext); var asyncEnumerator = await GetAsyncEnumerator(newQueryable, routeResult); return new StreamMergeAsyncEnumerator <T>(asyncEnumerator); })); }).ToArray(); var streamEnumerators = await Task.WhenAll(enumeratorTasks); if (_mergeContext.HasSkipTake()) { return(new NoPaginationStreamMergeEnumerator <T>(_mergeContext, streamEnumerators)); } if (_mergeContext.HasGroupQuery()) { return(new MultiAggregateOrderStreamMergeAsyncEnumerator <T>(_mergeContext, streamEnumerators)); } return(new MultiOrderStreamMergeAsyncEnumerator <T>(_mergeContext, streamEnumerators)); }
public NoPaginationStreamMergeEnumerator(StreamMergeContext <T> mergeContext, IEnumerable <IStreamMergeAsyncEnumerator <T> > sources) { _mergeContext = mergeContext; _skip = mergeContext.Skip; _take = mergeContext.Take; if (_mergeContext.HasGroupQuery()) { _enumerator = new MultiAggregateOrderStreamMergeAsyncEnumerator <T>(_mergeContext, sources); } else { _enumerator = new MultiOrderStreamMergeAsyncEnumerator <T>(_mergeContext, sources); } }