private async Task <TResult> EFCoreExecute <TResult>(IQueryable <T> newQueryable, RouteResult routeResult, Func <IQueryable, Task <TResult> > efQuery) { using (var scope = _mergeContext.CreateScope()) { scope.ShardingAccessor.ShardingContext = ShardingContext.Create(routeResult); return(await efQuery(newQueryable)); } }
private async Task <IAsyncEnumerator <T> > GetAsyncEnumerator(IQueryable <T> newQueryable, RouteResult routeResult) { using (var scope = _mergeContext.CreateScope()) { scope.ShardingAccessor.ShardingContext = ShardingContext.Create(routeResult); #if !EFCORE2 var enumator = newQueryable.AsAsyncEnumerable().GetAsyncEnumerator(); await enumator.MoveNextAsync(); #endif #if EFCORE2 var enumator = newQueryable.AsAsyncEnumerable().GetEnumerator(); await enumator.MoveNext(); #endif return(enumator); } }