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
Say I have one base class with multiple derived classes. if I want to query something based on a predicate that involves properties of the base class only, then EF Core generates a query that has an extra where clause involving the discriminator column.
First, the extra where clause would do absolutely nothing to help the query in any way, The predicate will return true for all rows in the result set.
Second, I think that if I were to make a covering index for the query in question, then I'd have to include the discriminator column in the index, (do excuse me if I'm wrong here)
Describe the solution you'd like
If we are querying on the DBSet of a base class, the clause should be omitted
Note
This problem is especially true for TPH mapping. I imagine that when the TPT mapping finally ships in EF Core, it will probably solve this issue outright, but the problem will remain for those unable to shift to TPT from TPH
The text was updated successfully, but these errors were encountered:
if I want to query something based on a predicate that involves properties of the base class only
A query can use only properties defined in the base class, but still return instances of multiple different types in the hierarchy. So, "involves properties of the base class only" does not mean the same as "involves any type in the hierarchy".
Issue #18106 is tracking an optimization that would result in no where clause for discriminators when querying for all types of entity in the hierarchy. Is this what you're looking for?
What problem are you trying to solve?
Say I have one base class with multiple derived classes. if I want to query something based on a predicate that involves properties of the base class only, then EF Core generates a query that has an extra
where
clause involving the discriminator column.First, the extra
where
clause would do absolutely nothing to help the query in any way, The predicate will return true for all rows in the result set.Second, I think that if I were to make a covering index for the query in question, then I'd have to include the discriminator column in the index, (do excuse me if I'm wrong here)
Describe the solution you'd like
If we are querying on the DBSet of a base class, the clause should be omitted
Note
This problem is especially true for TPH mapping. I imagine that when the TPT mapping finally ships in EF Core, it will probably solve this issue outright, but the problem will remain for those unable to shift to TPT from TPH
The text was updated successfully, but these errors were encountered: