Exemplo n.º 1
0
        private async IAsyncEnumerator <T> GetAsyncEnumeratorInternal(IAsyncQueryProvider provider, CancellationToken cancellationToken = default)
        {
            var enumerable = (IEnumerable <T>) await provider.ExecuteAsync <Task <object> >(_expression, cancellationToken);

            foreach (var element in enumerable)
            {
                yield return(element);
            }
        }
Exemplo n.º 2
0
        private async Task <object> ExecuteExpressionAsync <T>(CancellationToken cancellationToken)
        {
            IAsyncQueryProvider provider = this.dbContext.GetService <IAsyncQueryProvider>();

            var queryResult = new List <T>();

            using (var enumerator = provider.ExecuteAsync <T>(this.linqExpression).GetEnumerator())
            {
                while (await enumerator.MoveNext(cancellationToken))
                {
                    queryResult.Add(enumerator.Current);
                }
            }

            return(queryResult);
        }
Exemplo n.º 3
0
        private async static Task <TResult> Execute <TSource, TResult>(IQueryable <TSource> source, string methodName)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            IAsyncQueryProvider provider = source.Provider as IAsyncQueryProvider;

            if (provider == null)
            {
                throw new NotSupportedException();
            }

            MethodInfo method = typeof(AsyncQueryExtensions).GetMethod(methodName)
                                .MakeGenericMethod(typeof(TSource));

            return(await provider.ExecuteAsync <TResult>(
                       Expression.Call(null, method, source.Expression)));
        }
Exemplo n.º 4
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual IAsyncEnumerator <TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
 => _queryProvider.ExecuteAsync <IAsyncEnumerable <TResult> >(Expression).GetAsyncEnumerator(cancellationToken);
Exemplo n.º 5
0
 public virtual IAsyncEnumerator <TEntity> GetAsyncEnumerator(CancellationToken token = default)
 => QueryProvider.ExecuteAsync <IAsyncEnumerable <TEntity> >(Expression).GetAsyncEnumerator(token);
Exemplo n.º 6
0
 public IAsyncEnumerable <TResult> ExecuteAsync <TResult>(Expression expression)
 {
     return(AsyncUnderlyingProvider.ExecuteAsync <TResult>(Intercept(expression)));
 }
Exemplo n.º 7
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 IAsyncEnumerator <TResult> IAsyncEnumerable <TResult> .GetEnumerator()
 => _queryProvider.ExecuteAsync <IAsyncEnumerable <TResult> >(Expression).GetEnumerator();
Exemplo n.º 8
0
 /// <inheritdoc />
 public Task <TResult> ExecuteAsync <TResult>(Expression expression, CancellationToken token)
 {
     // execute query with rewritten expression
     return(provider.ExecuteAsync <TResult>(rewriter.Visit(expression), token));
 }
Exemplo n.º 9
0
 public Task <CouchList <TResult> > ToCouchListAsync(CancellationToken cancellationToken = default)
 => _queryProvider.ExecuteAsync <Task <CouchList <TResult> > >(_expression, cancellationToken);
 IAsyncEnumerator <TEntity> IAsyncEnumerable <TEntity> .GetEnumerator()
 => QueryProvider.ExecuteAsync <TEntity>(Expression).GetEnumerator();