1
美好的一天!我需要改變加入到左加入我的查詢 -實體框架 - 內連接到左連接
var query = (from sections in context.Sections
join themes in context.Themes on sections.SectionId equals themes.SectionId
join comments in context.Comments on themes.ThemeId equals comments.ThemeId
select new { sections.SectionId, sections.SectionTitle, themes.ThemeId, comments.CommentId } into x
group x by new { x.SectionId, x.SectionTitle } into g
select new SectionInfo
{
SectionId = g.Key.SectionId,
SectionTitle = g.Key.SectionTitle,
ThemeCount = g.Select(s => s.ThemeId).Count(),
CommentCount = g.Select(s => s.CommentId).Count()
}).ToList();
- 拜託,我不知道(
我必須替換哪部分查詢? – Skiminock
@ user2953816,則需要替換要轉換的每個連接。在我的口袋裏,你需要替換 '在上下文中加入主題。部分.SectionId等於themes.SectionId'。爲你的其他加入做同樣的事情 – Aducci
非常感謝你!有用! – Skiminock