Skip to content

Commit

Permalink
Query: Introduce QuerySqlGenerator.GenerateRootCommand as interceptio…
Browse files Browse the repository at this point in the history
…n point to capture top-level query expression (#28582)
  • Loading branch information
smitpatel authored Aug 5, 2022
1 parent bc8ca8f commit a65b456
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit a65b456

Please sign in to comment.