0
我非常新手使用LINQ,但我有幾個複雜的SQL查詢轉換爲LINQ的,所以我買Linqer的副本。不幸的是,我知道有一個SQL查詢Linqer無法轉換爲Linq,因爲Linqer無法將SQL轉換爲子連接。我希望有人能幫助我的LINQ的代碼,這個SQL查詢:LINQ查詢具有多個左加入
SELECT v.*, rci.CustomId, ci.EntryTime As CheckInTime, ci.Operator As CheckInOperator,
cis.Name As CheckInStation, co.EntryTime As CheckOutTime, co.Operator As CheckOutOperator,
cos.Name As CheckOutStation, cat.Name As Category, clr.Name As Clearance, r.ReasonForVisit As Reason,
s.SiteId + ' -- ' + s.SiteName As Site, e.LastName + ', ' + e.FirstName As Employee
FROM ((((((((((Visitor v LEFT JOIN VisitorEntry ci ON v.CheckInId = ci.Id)
LEFT JOIN VisitorEntry co ON v.CheckOutId = co.Id)
LEFT JOIN Station cis ON ci.StationId = cis.Id)
LEFT JOIN Station cos ON co.StationId = cos.Id)
LEFT JOIN Category cat ON v.CategoryId = cat.Id)
LEFT JOIN Clearance clr ON v.ClearanceId = clr.Id)
LEFT JOIN Reason r ON v.ReasonId = r.Id)
LEFT JOIN Site s ON v.SiteId = s.Id)
LEFT JOIN Employee e ON v.EmployeeId = e.Id)
LEFT JOIN RecordCustomId rci ON v.Id = rci.ParentId)
WHERE 1=1
(我有類似這樣的幾個SQL查詢,我需要轉換成的LINQ所以這就是爲什麼我有「WHERE」佔位符的查詢)
此外,我一直在看這篇博客,但我仍然無法理解如何將我的查詢翻譯: http://codingsense.wordpress.com/2009/06/16/multiple-list-left-join-in-linq/
謝謝! Mike