【发布时间】:2014-05-03 23:47:49
【问题描述】:
我正在 LINQ 中执行左连接,但遇到了问题。我的问题是我在 where 子句中对两个表进行比较,但我实际上无法访问“cat”表。如何访问左连接中的表?
var query = from apple in Apple
join ball in Ball on apple.Id equals ball.AppleId
join cat in Cat on ball.Id equals cat.BallId into leftJoin
join dog in Dog on ball.Id equals dog.BallId
where apple.Id == 5
// At this point cat is not accessable. Cannot resolve symbol "cat".
where dog.CatName == cat.Name
from cat in leftJoin.DefaultIfEmpty()
select new
{
// select stuff here...
};
【问题讨论】: