You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Query: Filter out entities that are using table splitting with a derived type #8973
changed the title [-]Query: Filter out entities that are using using table splitting with a derived type[/-][+]Query: Filter out entities that are using table splitting with a derived type[/+]on Jun 26, 2017
@anpete to write a note on details. @smitpatel We should either fix this or throw an exception in, for example, model validation so we can fix it post 2.0 without it being a breaking change. Please don't take a long time on a complex fix--if the fix isn't simple, then let's go the throw route.
@smitpatel The fix to try is to modify the two places in relational that apply discriminator predicates to SelectExpression: MaterializerFactory.CreateMaterializer and RelationalEntityQueryableExpressionVisitor.DiscriminateProjectionQuery. What we need to do is expand the cases for when we introduce discriminators by taking into account any related principal ETs that are sharing the same table. E.g. For model:
A
/
B --> C
Where B inherits A ,and B references C, and A, B, C all share the same table, then any direct query for Cs necessarily needs to have a B's discriminator predicate applied. Note, no join should be required because we are always table splitting.
Both above manifest from the fact that a random where predicate can arise for TPH scenario. With table splitting like above, that case becomes even more expanded since now, a shared type of a derived type will start having where.
It would be much more easier for our translation pipeline to work, if QM is modified instead of working around while translating. Though that will be decent amount of work with not enough time and then throw becomes the solution for 2.0.
If we want to support this for 2.0, then we can go with suggestion above and make additional check for owners.
Activity
[-]Query: Filter out entities that are using using table splitting with a derived type[/-][+]Query: Filter out entities that are using table splitting with a derived type[/+]anpete commentedon Jun 26, 2017
@AndriySvyryd What does this mean?
AndriySvyryd commentedon Jun 27, 2017
@anpete It will make more sense when #8976 is checked in
anpete commentedon Jun 29, 2017
I think we should consider reworking discriminators to be in-terms of QueryModel rewrites (like entity filters).
ajcvickers commentedon Jun 30, 2017
@anpete to write a note on details.
@smitpatel We should either fix this or throw an exception in, for example, model validation so we can fix it post 2.0 without it being a breaking change. Please don't take a long time on a complex fix--if the fix isn't simple, then let's go the throw route.
anpete commentedon Jun 30, 2017
@smitpatel The fix to try is to modify the two places in relational that apply discriminator predicates to
SelectExpression: MaterializerFactory.CreateMaterializerandRelationalEntityQueryableExpressionVisitor.DiscriminateProjectionQuery. What we need to do is expand the cases for when we introduce discriminators by taking into account any related principal ETs that are sharing the same table. E.g. For model:Where B inherits A ,and B references C, and A, B, C all share the same table, then any direct query for Cs necessarily needs to have a B's discriminator predicate applied. Note, no join should be required because we are always table splitting.
@AndriySvyryd has some context on this, too.
smitpatel commentedon Jun 30, 2017
@anpete - I prefer the idea of converting discriminators to where predicates at query model level. At present, we are in the world where creating SelectExpression for EntityQueryable can give rise to "where" clause in Select. That causes issues with joins where a flat QM can also generated a complex Select which requires to be pushdown.
https://github.com/aspnet/EntityFramework/blob/f034d5d18e57667e6b9af2424f8e6676340bae77/src/EFCore.Relational/Query/RelationalQueryModelVisitor.cs#L1537
Above code special case it for Left join cases.
And we still have bug for #8375
Both above manifest from the fact that a random where predicate can arise for TPH scenario. With table splitting like above, that case becomes even more expanded since now, a shared type of a derived type will start having where.
It would be much more easier for our translation pipeline to work, if QM is modified instead of working around while translating. Though that will be decent amount of work with not enough time and then throw becomes the solution for 2.0.
If we want to support this for 2.0, then we can go with suggestion above and make additional check for owners.
Your call what we should do for 2.0 ⌚️
AndriySvyryd commentedon Jun 30, 2017
I'll add a validation rule for 2.0 so we don't waste time on a temporary solution.
anpete commentedon Jun 30, 2017
Sounds good to me.
19 remaining items
ajcvickers commentedon Jan 27, 2018
@smitpatel This is a decent amount of work, so marking as priority high for 2.1 to indicate that it should be done soon.
Query: Allow entities which are table splitting with derived type
Query: Allow entities which are table splitting with derived type
Query: Allow entities which are table splitting with derived type
Query: Allow entities which are table splitting with derived type