This is based on PartialEvaluatingExpressionTreeVisitor but with a modification to avoid partially evaluating subtrees if the subtree is a binary expression between and a value. Normally, PartialEvaluatingExpressionTreeVisitor would eagerly compile certain types of subtree to make them "easier" to parse but this would mean we'd lose the metadata contained in the DynamicMemberMetadata.GetMember call and would just end up with the constant False evaluation return value when later visiting the QueryModel.
Unfortunately PartialEvaluatingExpressionTreeVisitor has a private constructor as of Relinq version 1.13.122.1 so some code is duplicated rather than inherited
Inheritance: System.Linq.Expressions.ExpressionTreeVisitor
Exemplo n.º 1
0
        public override Expression VisitExpression(Expression expression)
        {
            if (expression == null)
            {
                return(null);
            }
            if (expression.NodeType == ExpressionType.Lambda ||
                !this._partialEvaluationInfo.IsEvaluatableExpression(expression))
            {
                return(base.VisitExpression(expression));
            }
            Expression expressionTree = this.EvaluateSubtree(expression);

            if (expressionTree != expression)
            {
                return(CustomPartialEvaluatingExpressionTreeVisitor.EvaluateIndependentSubtrees(expressionTree));
            }
            else
            {
                return(expressionTree);
            }
        }
Exemplo n.º 2
0
 public Expression Process(Expression expressionTree)
 {
     ArgumentUtility.CheckNotNull <Expression>("expressionTree", expressionTree);
     return(CustomPartialEvaluatingExpressionTreeVisitor.EvaluateIndependentSubtrees(expressionTree));
 }