询问一个Linq表达式的写法
SQL语句是
SELECT ID,Subject,Content,(select Fullname from Person where ID = Owner) as Owner,Time
FROM BBS
WHERE Time >= @StartTime and Time <= @EndTime
我想问一下(select Fullname from Person where ID = Owner) as Owner这部分怎么转换。
我写的是
var query =
from bbs in estwdb.BBS
where 【省略】
select new
{
bbs.ID,
bbs.Subject,
bbs.Content,
Owner = 【这部分不会写】,
bbs.Time
};
请高手指教。
------解决方案--------------------
var query = from bbs in estwdb.BBS
join ps in Person
on bbs.Owner Equls ps.Owner
where 【省略】
select new {
bbs.ID,
bbs.Subject,
bbs.Content,
ps.Owner,
bbs.Time
};