Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursively visit when normalizing Any/All to Contains #34985

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions src/EFCore/Query/Internal/QueryOptimizingExpressionVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
if ((methodInfo == EnumerableMethods.AnyWithPredicate || methodInfo == QueryableMethods.AnyWithPredicate) && !negated)
{
var containsMethod = containsMethodDefinition.MakeGenericMethod(methodCallExpression.Method.GetGenericArguments()[0]);
return Expression.Call(null, containsMethod, methodCallExpression.Arguments[0], itemExpression);
return Visit(Expression.Call(null, containsMethod, methodCallExpression.Arguments[0], itemExpression));
}

if ((methodInfo == EnumerableMethods.All || methodInfo == QueryableMethods.All) && negated)
{
var containsMethod = containsMethodDefinition.MakeGenericMethod(methodCallExpression.Method.GetGenericArguments()[0]);
return Expression.Not(Expression.Call(null, containsMethod, methodCallExpression.Arguments[0], itemExpression));
return Visit(Expression.Not(Expression.Call(null, containsMethod, methodCallExpression.Arguments[0], itemExpression)));
}
}
}
Expand Down Expand Up @@ -278,15 +278,6 @@ protected override Expression VisitNewArray(NewArrayExpression newArrayExpressio
return newArrayExpression.Update(expressions);
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
protected override Expression VisitUnary(UnaryExpression unaryExpression)
=> unaryExpression.Update(Visit(unaryExpression.Operand));

private static Expression MatchExpressionType(Expression expression, Type typeToMatch)
=> expression.Type != typeToMatch
? Expression.Convert(expression, typeToMatch)
Expand Down
Loading