在这种关系中,联系人可能具有不同的电话号码,地址和电子邮件地址。
我需要一个显示[联系方式] [电话号码] [电子邮件] [地址]等的查询。
我不想显示所有相关的号码或电子邮件等。我只想显示默认的号码/电子邮件/地址。
到目前为止,这就是我所拥有的:
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
};
对于与多个电话相关联的联系人等,此查询将显示多行。
如何过滤查询,以便即使该列为空也显示带有“ Telephone_Default_ID”的查询?
任何建议都值得赞赏。