diff --git a/src/EFCore.Cosmos/Query/Pipeline/CosmosQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Pipeline/CosmosQueryableMethodTranslatingExpressionVisitor.cs index 3d3f094f62f..cf1fbb59806 100644 --- a/src/EFCore.Cosmos/Query/Pipeline/CosmosQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Pipeline/CosmosQueryableMethodTranslatingExpressionVisitor.cs @@ -23,6 +23,7 @@ public CosmosQueryableMethodTranslatingExpressionVisitor( ISqlExpressionFactory sqlExpressionFactory, IMemberTranslatorProvider memberTranslatorProvider, IMethodCallTranslatorProvider methodCallTranslatorProvider) + : base(subquery: false) { _model = model; _sqlExpressionFactory = sqlExpressionFactory; diff --git a/src/EFCore.InMemory/Query/Pipeline/InMemoryQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Pipeline/InMemoryQueryableMethodTranslatingExpressionVisitor.cs index c3dcfe12c75..f8d42811c9a 100644 --- a/src/EFCore.InMemory/Query/Pipeline/InMemoryQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.InMemory/Query/Pipeline/InMemoryQueryableMethodTranslatingExpressionVisitor.cs @@ -18,6 +18,7 @@ public class InMemoryQueryableMethodTranslatingExpressionVisitor : QueryableMeth private readonly IModel _model; public InMemoryQueryableMethodTranslatingExpressionVisitor(IModel model) + : base(subquery: false) { _expressionTranslator = new InMemoryExpressionTranslatingExpressionVisitor(); _projectionBindingExpressionVisitor = new InMemoryProjectionBindingExpressionVisitor(_expressionTranslator); diff --git a/src/EFCore.Relational/Query/Pipeline/RelationalQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/Pipeline/RelationalQueryableMethodTranslatingExpressionVisitor.cs index 34bff784775..e91433977b2 100644 --- a/src/EFCore.Relational/Query/Pipeline/RelationalQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/Pipeline/RelationalQueryableMethodTranslatingExpressionVisitor.cs @@ -28,6 +28,7 @@ public RelationalQueryableMethodTranslatingExpressionVisitor( IModel model, IRelationalSqlTranslatingExpressionVisitorFactory relationalSqlTranslatingExpressionVisitorFactory, ISqlExpressionFactory sqlExpressionFactory) + : base(subquery: false) { _sqlTranslator = relationalSqlTranslatingExpressionVisitorFactory.Create(model, this); _projectionBindingExpressionVisitor = new RelationalProjectionBindingExpressionVisitor(this, _sqlTranslator); @@ -39,6 +40,7 @@ private RelationalQueryableMethodTranslatingExpressionVisitor( IModel model, RelationalSqlTranslatingExpressionVisitor sqlTranslator, ISqlExpressionFactory sqlExpressionFactory) + : base(subquery: true) { _model = model; _sqlTranslator = sqlTranslator; diff --git a/src/EFCore/Query/Pipeline/QueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore/Query/Pipeline/QueryableMethodTranslatingExpressionVisitor.cs index 83d87b24047..53128597429 100644 --- a/src/EFCore/Query/Pipeline/QueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore/Query/Pipeline/QueryableMethodTranslatingExpressionVisitor.cs @@ -13,6 +13,13 @@ namespace Microsoft.EntityFrameworkCore.Query.Pipeline { public abstract class QueryableMethodTranslatingExpressionVisitor : ExpressionVisitor { + private readonly bool _subquery; + + protected QueryableMethodTranslatingExpressionVisitor(bool subquery) + { + _subquery = subquery; + } + protected override Expression VisitConstant(ConstantExpression constantExpression) => constantExpression.IsEntityQueryable() ? CreateShapedQueryExpression(((IQueryable)constantExpression.Value).ElementType) @@ -424,8 +431,6 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp break; } } - - throw new NotImplementedException("Unhandled method: " + methodCallExpression.Method.Name); } // TODO: Skip ToOrderedQueryable method. See Issue#15591 @@ -435,7 +440,9 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp return Visit(methodCallExpression.Arguments[0]); } - return base.VisitMethodCall(methodCallExpression); + return _subquery + ? (Expression)null + : throw new NotImplementedException("Unhandled method: " + methodCallExpression.Method.Name); } protected Type CreateTransparentIdentifierType(Type outerType, Type innerType)