private NhPartialEvaluatingExpressionVisitor( PartialEvaluationInfo partialEvaluationInfo, PreTransformationParameters preTransformationParameters) { _partialEvaluationInfo = partialEvaluationInfo; _preTransformationParameters = preTransformationParameters; }
private PartialEvaluatingExpressionTreeVisitor(Expression treeRoot, PartialEvaluationInfo partialEvaluationInfo) { ArgumentUtility.CheckNotNull("treeRoot", treeRoot); ArgumentUtility.CheckNotNull("partialEvaluationInfo", partialEvaluationInfo); _partialEvaluationInfo = partialEvaluationInfo; }
private PartialEvaluatingExpressionVisitor( PartialEvaluationInfo partialEvaluationInfo, IEvaluatableExpressionFilter evaluatableExpressionFilter) { ArgumentUtility.CheckNotNull("partialEvaluationInfo", partialEvaluationInfo); ArgumentUtility.CheckNotNull("evaluatableExpressionFilter", evaluatableExpressionFilter); _partialEvaluationInfo = partialEvaluationInfo; _evaluatableExpressionFilter = evaluatableExpressionFilter; }
/// <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> public virtual Expression ExtractParameters([NotNull] Expression expression) { var oldPartialEvaluationInfo = _partialEvaluationInfo; _partialEvaluationInfo = EvaluatableTreeFindingExpressionVisitor .Analyze(expression, _evaluatableExpressionFilter); try { return(Visit(expression)); } finally { _partialEvaluationInfo = oldPartialEvaluationInfo; } }
/// <remarks> /// Parameters are evaluatable if they are supplied by evaluatable expression. /// Look up lambda defining the parameter, up the ancestor list and check if method call to which it is passed is on evaluatable /// instance or extension method accepting evaluatable arguments. /// Note that lambda body is visited prior to parameters. /// Since method call is visited in the order [instance, arguments] and extension methods get instance as first parameter /// the source of the parameter is already visited and its evaluatability established. /// </remarks>> private ParameterStatus CalcParameterStatus(ParameterExpression expression) { if (expression == null) { throw new ArgumentNullException(nameof(expression)); } var result = new ParameterStatus { Expression = expression }; foreach (var ancestor in _ancestors) { if (result.MethodArgumentAcceptingLambda == null && IsParameterOwner(ancestor, expression)) { result.MethodArgumentAcceptingLambda = result.OwningExpression = (LambdaExpression)ancestor; } else if (result.MethodArgumentAcceptingLambda != null) { if (ancestor.NodeType == ExpressionType.Call) { result.MethodCallInvokingLambda = (MethodCallExpression)ancestor; result.IsEvaluatable = result.MethodCallInvokingLambda.Object != null ? PartialEvaluationInfo.IsEvaluatableExpression(result.MethodCallInvokingLambda.Object) : result.MethodCallInvokingLambda.Arguments.All(a => a == result.MethodArgumentAcceptingLambda || ( PartialEvaluationInfo.IsEvaluatableExpression(a) // member expressions on e.g. repository creating query instances must be evaluated into constants // but parameters accepting values from them are not evaluatable && !typeof(IQueryable).IsAssignableFrom(a.Type))); return(result); } result.MethodArgumentAcceptingLambda = ancestor; } } return(result); }
private ParameterExtractingExpressionVisitor( PartialEvaluationInfo partialEvaluationInfo, QueryContext queryContext) { _partialEvaluationInfo = partialEvaluationInfo; _queryContext = queryContext; }
private PartialEvaluatingExpressionTreeVisitor(Expression treeRoot, PartialEvaluationInfo partialEvaluationInfo) { _partialEvaluationInfo = partialEvaluationInfo; }
private NhPartialEvaluatingExpressionVisitor(PartialEvaluationInfo partialEvaluationInfo) { _partialEvaluationInfo = partialEvaluationInfo ?? throw new ArgumentNullException(nameof(partialEvaluationInfo)); }