我有以下部分Linq查詢:Linq - 如何構建不含'join'關鍵字的查詢?
var query = from ri in RouteInstance
join rir in RouteInstanceRules on ri.RouteInstanceID equals rir.RouteInstanceID
join rl in RoutingLocation on rir.RoutingLocationID equals rl.RoutingLocationID
join rlh in RoutingLocationHistory on rl.RoutingLocationID equals rlh.RoutingLocationID
where rlh.RouteTakenTime >= new System.DateTime(2011,2,4) && rlh.RouteTakenTime <= new System.DateTime(2011,2,5)
There is a 1:M relationship between RouteInstance and RouteInstanceRules
There is a 1:M relationship between RouteInstanceRules and RoutingLocation
There is a 1:M relationship between RoutingLocation and RoutingLocationHistory
由於這些關係使用FKS執行,因此已知L2S,我應該能夠構造此查詢,而無需使用「加入」的關鍵字。但是,我很難理解如何去做。
謝謝。
這是你在找什麼? http://blogs.msdn.com/b/charlie/archive/2007/02/20/one-to-many-and-joins.aspx從這篇文章http://stackoverflow.com/questions/4133455/linq-加入混亂。看起來你已經在那裏發表評論。 – Chris 2011-02-09 14:09:36
@Chris--我不認爲這是完全一樣的,我對我發佈的問題的答案並不滿意。但是,謝謝。 – 2011-02-09 14:22:49