示例#1
0
 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));
     }
 }
示例#2
0
        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);
            }
        }