-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Support OfType<T>()
within Include
expressions on base-class-typed collection navigations
#30683
Comments
Full exception, for completeness's sake:
|
This was also referenced here #3910 (comment), where the reporter "solved" the issue by materializing first, then filtering in memory. This is far from ideal, however, especially when dealing with either of:
|
You can handle this by rewrite line:
This will generate SQL with filtered join on Discriminator (TPH, TPT...I didnt't try TPC) |
Aha! That works like a charm on the TPC schema I'm experimenting with. Many thanks for sharing! That unsticks me in my particular scenario. It strikes me that supporting If a maintainer feels this is resolved, though, no major gripes from me. E: For slightly more context, when used on a TPC schema, the suggested filter
correctly generates a query that targets only the |
Note from triage: consider supporting the |
This solution is working in |
Suppose one has the following schema:
And wanted to quickly find information about an
AppUser
and all of their "Martial" skills.Normally, I'd expect to be able to do:
This, however fails, since
OfType
is not inMicrosoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.SupportedFilteredIncludeOperations
.OfType<T>()
is valid withinSelect
statements, however. e.g. this would work:Ideally,
OfType
should be supported for base-typed collection navigations.The text was updated successfully, but these errors were encountered: