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

Query: Throw for unknown method encountered in QueryableMethodTranslator #16302

Merged
merged 1 commit into from
Jun 27, 2019
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public CosmosQueryableMethodTranslatingExpressionVisitor(
ISqlExpressionFactory sqlExpressionFactory,
IMemberTranslatorProvider memberTranslatorProvider,
IMethodCallTranslatorProvider methodCallTranslatorProvider)
: base(subquery: false)
{
_model = model;
_sqlExpressionFactory = sqlExpressionFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -39,6 +40,7 @@ private RelationalQueryableMethodTranslatingExpressionVisitor(
IModel model,
RelationalSqlTranslatingExpressionVisitor sqlTranslator,
ISqlExpressionFactory sqlExpressionFactory)
: base(subquery: true)
{
_model = model;
_sqlTranslator = sqlTranslator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down