joelgullander
Help with Entity Framework Core: Union of Two Queries with Inherited Types Failing
Hi everyone,
I’m working on a project using EF Core and AutoMapper with HotChocolate for GraphQL. I’m trying to combine two queries using Union, but I'm encountering an error.
Scenario:
I have two inherited types: AppointmentInvitationEntity and NonAppointmentInvitationEntity, both inheriting from InvitationEntity. I need to query both types, filter them based on identifier and systemType, and combine the results into a single IQueryable<InvitationModel> using Union.
Here’s my current code:
The Problem:
When I run this code, I get the following error:
I’ve tried removing ProjectTo, but that leads to other issues with how the two entity types are combined. EF Core seems to have trouble combining two queries with different navigation properties, even though I’m using ProjectTo to project both into the same InvitationModel.
My Question:
1. Why does this fail with the error about 'Include' operations even though I’m using ProjectTo to project both queries into the same type?
2. Is there a better approach to combine these two queries at the database level without loading everything into memory?
Thanks in advance for any help or insights!
2 replies