-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Multiple entity support for ExecuteUpdate #31408
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
Conversation
SET [c].[ContactName] = N'Updated' | ||
FROM [Customers] AS [c] | ||
WHERE [c].[CustomerID] LIKE N'F%' | ||
INNER JOIN ( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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.
Closes #31406
Fixes #31349