Polymorphic query handling in EF Core - Thoughts?
So I'm having to deal a lot with entity polymorphism and querying the db to avoid having to execute multiple separate queries. I'm not sure about best practices here, but i also have to eagerload certain nav props from the derived types. Anyone know a better way than this?
9 Replies
you can use
.Include(_ => (_ as InternalAccommodation).PriceDetails)
hmm yeah that might be cleaner, but then I have to suppress the null warning on the cast
yeah the warning is a little bothering
could place the switch in its own class and namespace and use pragma warning disable
lol
it doesn't look to me that you really need thet switch
i mean it depends on how you want to organize the code
ur probably right, at that point its just building the query and it doesn't impact performance either way if none of those requests are materialized if they don't exist
seems a quite wild query
why is not PriceDetails in CoreProduct?
beacuse different products have different price details
and why a single query is trying to extract such heterogeneous objects/relations?