1
我的链接查询LINQ的加入 - 为您在记录连接表
var q = from l in db.Locations
select new LocationWrap {
Location = l
返回每个位置
一行,直到我补充一下:
var q = from l in db.Locations
join lcl in db.Location_Catering_Links on l.ID equals lcl.LID into catering from lcl in catering.DefaultIfEmpty()
select new LocationWrap {
Location = l,
hasCatering = (lcl != null)
它然后返回许多位置记录(如很多,因为有)。我相信它可能会做一个左外连接,当我需要的是一个布尔是否有任何餐饮记录。
我该怎么做?
你在答案中有一个错字。它应该是'x => x.ID == l.ID'。 – Marco
@Serv oops。非常感谢你 ! – Christos