Ejemplo n.º 1
0
        public object Execute(Expression expression)
        {
            var resultVisitor = new IncludeRewriterVisitor();

            expression = resultVisitor.Modify(expression);
            if (resultVisitor.Count)
            {
                return(_queryProvider.Execute(expression));
            }

            if (resultVisitor.SkipTake)
            {
                expression = RemoveSkipAndTake(expression);
            }

            try
            {
                return(ExecuteInternalMethod.MakeGenericMethod(Type).Invoke(this, new object[] { expression, resultVisitor }));
            }
            catch (TargetInvocationException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                throw;
            }
        }
Ejemplo n.º 2
0
        public async Task <TResult> ExecuteAsync <TResult>(Expression expression, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var resultVisitor = new IncludeRewriterVisitor();

            expression = resultVisitor.Modify(expression);

            if (resultVisitor.Count)
            {
                return(await _queryProvider.ExecuteAsync <TResult>(expression, cancellationToken));
            }

            if (resultVisitor.SkipTake)
            {
                expression = RemoveSkipAndTake(expression);
            }

            try
            {
                dynamic task = ExecuteInternalAsyncMethod.MakeGenericMethod(Type)
                               .Invoke(this, new object[] { expression, resultVisitor, cancellationToken });
                return(await task.ConfigureAwait(false));
            }
            catch (TargetInvocationException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                throw;
            }
        }
Ejemplo n.º 3
0
        internal object ExecuteInternal <T>(Expression expression, IncludeRewriterVisitor visitor)
        {
            var future = ExecuteQueryTreeFuture <T>(expression);
            var items  = future.GetEnumerable();

            if (visitor.SingleResult)
            {
                return(GetValue(items, visitor.SingleResultMethodName));
            }
            return(items);
        }
Ejemplo n.º 4
0
        public IFutureEnumerable <TResult> ExecuteFuture <TResult>(Expression expression)
        {
            var resultVisitor = new IncludeRewriterVisitor();

            expression = resultVisitor.Modify(expression);
            if (resultVisitor.SkipTake)
            {
                expression = RemoveSkipAndTake(expression);
            }

            return(ExecuteQueryTreeFuture <TResult>(expression));
        }
Ejemplo n.º 5
0
        internal async Task <object> ExecuteInternalAsync <T>(Expression expression, IncludeRewriterVisitor visitor, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var future = ExecuteQueryTreeFuture <T>(expression);
            var items  = await future.GetEnumerableAsync(cancellationToken).ConfigureAwait(false);

            if (visitor.SingleResult)
            {
                return(GetValue(items, visitor.SingleResultMethodName));
            }
            return(items);
        }
Ejemplo n.º 6
0
        public IFutureValue <TResult> ExecuteFutureValue <TResult>(Expression expression)
        {
            var resultVisitor = new IncludeRewriterVisitor();

            expression = resultVisitor.Modify(expression);

            if (resultVisitor.Count)
            {
                return(_queryProvider.ExecuteFutureValue <TResult>(expression));
            }

            if (resultVisitor.SkipTake)
            {
                expression = RemoveSkipAndTake(expression);
            }

            return(ExecuteQueryTreeFutureValue <TResult>(expression));
        }