Ejemplo n.º 1
0
        static async Task <R> Bind <R>(CancellationToken cancellationToken, Expression <Func <R> > bind)
        {
            var mce = (MethodCallExpression)bind.Body;

            IQueryable query = (IQueryable)ExpressionEvaluator.Eval(mce.Arguments.FirstEx()) !;

            List <Expression> otherExpressions = mce.Arguments.Skip(1).Select(a => (Expression)ExpressionEvaluator.Eval(a) !).ToList();

            var mc2 = Expression.Call(mce.Method, otherExpressions.PreAnd(query.Expression));

            var provider = (IQueryProviderAsync)query.Provider;

            var value = await provider.ExecuteAsync(mc2, cancellationToken);

            return((R)value !);
        }