2010-08-23 200 views
0

這是我的查詢:加入左LINQ to SQL中

Dim bugs = (From b In bugCon.bugs Where sctUserIds.Contains(b.Developer.Value) Order By b.bg_id Select Bug = b, Project = b.project).ToList 

目前這樣做「錯誤」和「項目」之間的內部連接。我如何將它變成左連接?

回答

0

我還沒有測試過這個,但下面的查詢應該讓你朝着正確的方向前進。關鍵是將...加入語法並使用DefaultIfEmpty()

from b in context.Bugs 
join p in context.Projects 
on b.projectID equals p.projectID into BugProjects 
where sctUserIds.Contains(b.Developer.Value) 
from bugProjects in BugProjects.DefaultIfEmpty() 
select new { 
    Name = p.Name, 
    ... 
    BugProjects = bugProjects 
}