diff --git a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs index 3239263b9a6..74e5ff100c8 100644 --- a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs @@ -288,7 +288,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp // Server), we need to fall back to the previous IN translation. if (method.IsGenericMethod && method.GetGenericMethodDefinition() == QueryableMethods.Contains - && UnwrapAsQueryable(methodCallExpression.Arguments[0]) is ParameterQueryRootExpression parameterSource + && methodCallExpression.Arguments[0] is ParameterQueryRootExpression parameterSource && TranslateExpression(methodCallExpression.Arguments[1]) is SqlExpression item && _sqlTranslator.Visit(parameterSource.ParameterExpression) is SqlParameterExpression sqlParameterExpression) { @@ -300,12 +300,6 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp .UpdateResultCardinality(ResultCardinality.Single); return shapedQueryExpression; } - - static Expression UnwrapAsQueryable(Expression expression) - => expression is MethodCallExpression { Method: { IsGenericMethod: true } method } methodCall - && method.GetGenericMethodDefinition() == QueryableMethods.AsQueryable - ? methodCall.Arguments[0] - : expression; } return translated;