object IQueryProvider.Execute(Expression expression)
        {
            var expanded  = expression.Expand();
            var optimized = LinqKitExtension.QueryOptimizer(expanded);

            return(_query.InnerQuery.Provider.Execute(optimized));
        }
        // The following four methods first call ExpressionExpander to visit the expression tree, then call
        // upon the inner query to do the remaining work.
        IQueryable <TElement> IQueryProvider.CreateQuery <TElement>(Expression expression)
        {
            var expanded  = expression.Expand();
            var optimized = LinqKitExtension.QueryOptimizer(expanded);

            return(_query.InnerQuery.Provider.CreateQuery <TElement>(optimized).AsExpandable());
        }
Esempio n. 3
0
        public Task <object> ExecuteAsync(Expression expression, CancellationToken cancellationToken)
        {
            var asyncProvider = _query.InnerQuery.Provider as IDbAsyncQueryProvider;
            var expanded      = expression.Expand();
            var optimized     = LinqKitExtension.QueryOptimizer(expanded);

            if (asyncProvider != null)
            {
                return(asyncProvider.ExecuteAsync(optimized, cancellationToken));
            }
            return(Task.FromResult(_query.InnerQuery.Provider.Execute(optimized)));
        }
Esempio n. 4
0
        public Task <TResult> ExecuteAsync <TResult>(Expression expression, CancellationToken cancellationToken)
        {
#if EFCORE
            var asyncProvider = _query.InnerQuery.Provider as IAsyncQueryProvider;
#else
            var asyncProvider = _query.InnerQuery.Provider as IDbAsyncQueryProvider;
#endif
            var expanded  = expression.Expand();
            var optimized = LinqKitExtension.QueryOptimizer(expanded);
            if (asyncProvider != null)
            {
                return(asyncProvider.ExecuteAsync <TResult>(optimized, cancellationToken));
            }

            return(Task.FromResult(_query.InnerQuery.Provider.Execute <TResult>(optimized)));
        }