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

Allow ExecuteUpdate to update properties of multiple queries as long as they map to a single table #31406

Closed
roji opened this issue Aug 3, 2023 · 0 comments · Fixed by #31408
Assignees
Labels
area-bulkcud closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Milestone

Comments

@roji
Copy link
Member

roji commented Aug 3, 2023

Our current ExecuteUpdate logic checks that only one entity type is updated by all the setters; this blocks scenarios such as the following:

Updating columns mapped to multiple owned entities (and the owner):

_ = await ctx.Blogs.ExecuteUpdateAsync(s => s
    .SetProperty(b => b.Name, "foo")
    .SetProperty(b => b.BlogDetails.Details, "bar"));

(note: this will also apply to complex types)

Updating columns mapped to a single table within a TPT hierarchy:

_ = await ctx.SpecialBlogs.ExecuteUpdateAsync(
    s => s.SetProperty(b => b.SpecialProperty, "foo"));

Updating the main table of an entity with entity splitting

As long as updates only affect columns on the main table, this now works.

Unfortunately, updates to any of the split tables fail on SQL Server for other, architectural reasons, see #31407. On Sqlite they pass, because a different query shape is generated.

@roji roji added type-enhancement closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported area-bulkcud labels Aug 3, 2023
@roji roji added this to the 8.0.0 milestone Aug 3, 2023
@roji roji self-assigned this Aug 3, 2023
roji added a commit to roji/efcore that referenced this issue Aug 3, 2023
roji added a commit to roji/efcore that referenced this issue Aug 3, 2023
roji added a commit that referenced this issue Aug 9, 2023
roji added a commit to roji/efcore that referenced this issue Aug 9, 2023
@ajcvickers ajcvickers modified the milestones: 8.0.0, 8.0.0-rc1 Aug 19, 2023
@ajcvickers ajcvickers changed the title Allow ExecuteUpdate to update properties of multiple queries as long as the map to a single table Allow ExecuteUpdate to update properties of multiple queries as long as they map to a single table Oct 4, 2023
@ajcvickers ajcvickers modified the milestones: 8.0.0-rc1, 8.0.0 Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-bulkcud closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants