In this relationship, Contacts may have different phone numbers, addresses and email addresses.
I need a query that shows [Contact Details][Telephone Number][Email][Address]etc.
I dont want to show all of the related numbers or emails etc. I would like to show just the default Number/Email/address.
So far, This is what I have:
var contacts =
from con in dc.Contacts_Tables
join com in dc.Companies_Tables on con.Company_ID equals com.Company_ID into comp from compa in comp.DefaultIfEmpty()
join em in dc.Email_Tables on con.Contact_ID equals em.Contact_ID into ema from emai in ema.DefaultIfEmpty()
join ad in dc.Contact_Address_Tables on con.Contact_ID equals ad.Contact_ID into add from addr in add.DefaultIfEmpty()
join tel in dc.Contacts_Telephone_Tables on con.Contact_ID equals tel.Contact_ID into tele from telep in tele.DefaultIfEmpty()
orderby con.Contact_FirstName
select new
{
ID = con.Contact_ID,
FirstName = con.Contact_FirstName,
MidName = con.Contact_Midname,
Surname = con.Contact_Surname,
Company = compa.Company_Name,
Telephone = telep.Telephone_Number,
Email = emai.Email_Address,
Address = addr.Address,
Notes = con.Notes
};
This query will show more than a row for contacts who have more than one telephone associated etc.
How can I filter the query so it shows those with "Telephone_Default_ID" even if this column is empty?
Any suggestion is appreciated.