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: Introduce QuerySqlGenerator.GenerateRootCommand as interception point to capture top-level query expression #28582

Merged
1 commit merged into from
Aug 5, 2022
Merged
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
14 changes: 12 additions & 2 deletions src/EFCore.Relational/Query/QuerySqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ public virtual IRelationalCommand GetCommand(Expression queryExpression)
{
_relationalCommandBuilder = _relationalCommandBuilderFactory.Create();

GenerateRootCommand(queryExpression);

return _relationalCommandBuilder.Build();
}

/// <summary>
/// Generates the command for the given top-level query expression. This allows providers to intercept if an expression
/// requires different processing when it is at top-level.
/// </summary>
/// <param name="queryExpression">A query expression to print in command.</param>
protected virtual void GenerateRootCommand(Expression queryExpression)
{
switch (queryExpression)
{
case SelectExpression selectExpression:
Expand All @@ -90,8 +102,6 @@ public virtual IRelationalCommand GetCommand(Expression queryExpression)
default:
throw new InvalidOperationException();
}

return _relationalCommandBuilder.Build();
}

/// <summary>
Expand Down