我参加了一次发言,并试图为此而向SQl提问,但没有成功。
SELECT ur.UserName, ur.LandmarkRef, lt.Date, l.Place
FROM
tbl_Users ur
LEFT OUTER JOIN tbl_LandMarks l ON ur.LandmarkRef = l.LandMarkID
INNER JOIN tbl_LandmarkTypes lt ON l.LandmarkTypeRef equals lt.LandmarkTypeID
WHERE ur.UserId == pUserId
The following is the Linq-to-SQL query which does not work if I use LEFT OUTER JOIN
UserDBDataContext lDc = new UserDBDataContext();
var lU= (from ur in lDc.tbl_Users
join l in lDc.tbl_LandMarks on ur.LandmarkRef equals l.LandMarkID into Lmark
from lmk in Lmark.DefaultIfEmpty()
join lt in lDc.tbl_LandmarkTypes on lmk.LandmarkTypeRef equals lt.LandmarkTypeID
where ur.UserId == pUserId
select new { ur.UserName, ur.LandmarkRef, lc.Date, lmk.Place});
在这里,土地保有权实际上是一个任择领域,因此它可能是全国土地基金,因此,由于国家土地保有权组织在土地保有权方面的价值,它不会发挥作用,也不会返回。 后者在LQ-to-SQL中工作,但不是在LINQ-to-SQL中工作。