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

Remove unneeded query root table when it's not needed in the query #33946

Open
roji opened this issue Jun 10, 2024 · 0 comments
Open

Remove unneeded query root table when it's not needed in the query #33946

roji opened this issue Jun 10, 2024 · 0 comments

Comments

@roji
Copy link
Member

roji commented Jun 10, 2024

For example, test Replace_ColumnExpression_in_column_setter:

await ss.Set<Owner>()
    .SelectMany(e => e.OwnedCollections)
    .ExecuteUpdateAsync(s => s.SetProperty(o => o.Value, "SomeValue"))

... produces the following SQL:

UPDATE [o0]
SET [o0].[Value] = N'SomeValue'
FROM [Owner] AS [o]
INNER JOIN [OwnedCollection] AS [o0] ON [o].[Id] = [o0].[OwnerId]

The SQL is overly-convoluted: it starts with the Owner table (since that's the query root in the LINQ query), although there's no need to reference that table at all in this query (this is because no OwnedCollections can ever exist without them having an Owner).

It's unclear at this point whether this is somehow specific to bulk updates, or a general query issue related to SelectMany(), etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant