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

Extract SelectExpression construction out to RelationalQueryableMethodTranslatingEV #32877

Merged
merged 2 commits into from
Jan 22, 2024

Conversation

roji
Copy link
Member

@roji roji commented Jan 21, 2024

This continues the query architecture work, starting to extract closed logic out of SelectExpression and into RelationalQueryableMethodTranslatingExpressionVisitor, specifically the logic around constructing a root SelectExpression for an entity type (with TPC/TPT/TPH/entity splitting logic/etc.). After this, only regular/direct constructors are left on SelectExpression, which accept its various clauses directly ((nothing that knows about IEntityType; these are also organized/simplified).

This is mostly easy moving around of code, no actual meaningful changes.

@roji roji requested a review from a team January 21, 2024 16:57
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
[EntityFrameworkInternal]
SelectExpression Select(SqlExpression? projection, SqlAliasManager sqlAliasManager);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this PR removes Select factory methods from SqlExpressionFactory - at least for now. There's no point in simply duplicating SelectExpression constructors on the factory, just as an additional indirect thing. We may re-introduce them later at some point if that makes sense.

/// <summary>
/// Used to create a root <see cref="SelectExpression" /> representing a query of the given entity type.
/// </summary>
protected virtual SelectExpression CreateSelect(IEntityType entityType)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly a copy-paste (plus small reorganize/refactor) of the SelectExpression constructor which accepted an IEntityType. SelectExpression should ultimately be oblivious of our model, representing a pure server-side SQL construct.

* - Principal can be any type in TPH/TPT or leaf type in TPC
* - Dependent side can be TPH or TPT but not TPC
***/
private void AddConditions(SelectExpression selectExpression, IEntityType entityType)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this additional logic which was added on top of the SelectExpression constructor, and which lived in SqlExpressionFactory for some reason. After this PR it is all now concentrated inside QueryableMethodTranslatingEV.

@@ -4412,24 +3837,6 @@ private static Expression MakeNullable(Expression expression, bool nullable)
}
: expression;

private static IEnumerable<IProperty> GetAllPropertiesInHierarchy(ITypeBase structuralType)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also have those sprinkled around in QueryableMethodTranslatingExpressionVisitors, consider DRYing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, will do.

@roji roji merged commit 4380d3e into dotnet:main Jan 22, 2024
7 checks passed
@roji roji deleted the SelectConstruction branch January 22, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants