The Entity I am trying to query is an association table with a type column. The type column determines one entity it links off to. Example. OrganizationContactAssociation { OrganizationId, ContactId, Id, AssociationType }
If AssociationType = Email then Id is an EmailId and the Navigation Property for ContactEmail is the correct one to use.
Because of this I tried:
return await DataService.EntityManager.OrganizationContactAssociations
.Where(e => e.InActive == false && e.ContactId == pContactId)
.Include(e => e.ContactAddress)
.Include(e => e.ContactAddress.Address)
.Include(e => e.ContactAddress.Type)
.Include(e => e.ContactPhone)
.Include(e => e.ContactPhone.Phone)
.Include(e => e.ContactPhone.Type)
.Include(e => e.ContactJobTitle)
.Include(e => e.ContactJobTitle.JobTitle)
.Include(e => e.ContactEmail)
.Include(e => e.ContactEmail.Email)
.ExecuteAsync();
This causes an inner join on each table rather then a left join.
I tried changing the Id to allow nulls which then allows the references to be 0 to many. This causes an error.
I tried creating Entities of type OrganizationContactAssociation for each type. This does not allow me to query those sub/inherited entities directly.
I tried querying each individual type separately, this causes only the last query to be in the cache. I can not allow for the lazy load type because I have a deleted state to each entity, and do not delete any entities. Therefore, I can only display those entities where the deleted states is false.