Skip to content

Conversation

roji
Copy link
Member

@roji roji commented Aug 3, 2023

Closes #31406
Fixes #31349

@roji roji requested a review from maumar August 3, 2023 10:41
SET [c].[ContactName] = N'Updated'
FROM [Customers] AS [c]
WHERE [c].[CustomerID] LIKE N'F%'
INNER JOIN (
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 SQL becomes seemingly more complex. However, the simpler SQL was only the result of logic for ignoring Distinct in cases where it's totally useless (i.e. when placed direct on entity types which have unique PKs, so necessarily a no-op). which doesn't fit so well with the new code. The user can simply remove their useless Distinct() if they want.

Copy link
Member Author

Choose a reason for hiding this comment

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

BTW thinking about this, if we really want to remove useless Distincts, that should probably be done more generally in the query pipeline (though again, it's the kind of optimization which only speeds up badly-written LINQ queries).

/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public sealed class TpcTablesExpression : TableExpressionBase
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to expose it in order to recognize it in ExecuteUpdate translation, to throw the appropriate error message; it's still internal (another part of opening things up a bit).

}

// Generate the INNER JOIN around the original query, on the PK properties.
var outer = (ShapedQueryExpression)Visit(new EntityQueryRootExpression(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.

Most of these changes are simply refactoring/moving around the code.

@roji roji requested a review from a team August 3, 2023 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants