-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Aggregate on optional dependent lacks condition #23230
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
|
Yes, despite the name |
In this case left join isn't actually needed, but a condition on the nullable This query works correctly: context.Set<Root>().Any(r => r.RequiredSingle != null) SELECT CASE
WHEN EXISTS (
SELECT 1
FROM [Root] AS [r]
WHERE [r].[RequiredSingle_Bool] IS NOT NULL) THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END But these also lack the condition: context.Set<Root>().Select(r => r.RequiredSingle).Select(e => e.Id == removedId) SELECT CASE
WHEN [r].[Id] = @__removedId_0 THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END
FROM [Root] AS [r] context.Set<Root>().Select(r => r.RequiredSingle).AsNoTracking() SELECT [r].[Id], [r].[RequiredSingle_Bool], [r].[RequiredSingle_Single_Bool]
FROM [Root] AS [r] |
This would redefine the concept of property access on owned entities. Basically, "e.Id" in the query cannot be accessed by just using the column from the database. And we need to add checks for principal (whole chain) to verify existence of the instance everytime any of the shared columns are used (except in final materialization). Do we want to go down that path? |
If we don't then we need to throw in this case as context.Set<Root>().Select(r => r.RequiredSingle).Select(e => e.Id == removedId); is different from context.Set<Root>().Select(e => e.Id == removedId)
That's different because there's no other way of getting the shared behavior and non-shared behavior is available without casting. |
Design, we should generate conditional in SQL to access property conditionally. |
See
GraphUpdatesSqlServerTest.Owned.Required_one_to_one_are_cascade_deleted
The text was updated successfully, but these errors were encountered: