Given EF entities defined as follows
class Person { int PersonID; string Name; string Title; }
class ContactType { int TypeID; string TypeString; } // phone # types - mobile, home, work etc.
class PersonContact { int PersonID, int ContactTypeID, string ContactText; bool IsDefault; }
Where a person can have multiple phone #’s and even multiple mobile #’s
Looking for ways to display all Persons in a table structure as follows
PersonID, Name, Title, PrimaryContact, MobileNumber
Where PrimaryContact is the PersonContact Record with IsDefault = true
and
WHERE MobileNumber is “A” PersonContact Record with PersonContact.ContactType = ContactType.TypeID and ContactType.TypeString = “Mobile”
NOTE –
PrimaryContact is a lookup into PersonContact
MobileNumber is ALSO a lookup into PersonContact
They could point to the same PersonContact record or could be different depending on IsDefault = true
ALSO There could be multiple “Mobile” PersonContact records for a person
Try this below.
Sadly i think this might result in a select n + 1 type query 🙁