一些久违的开发人员在没有文档的情况下留下了以下LINQ查询,我很难理解它的作用(因此,如果它正确的话)。有人可以通过将其分解成片段或提供SQL等价物来帮助翻译吗?
Dim matches = From mc In mcs _
Join ri In r.Items On ri.VIN Equals mc.VIN _
Group Join t In (From t In claimTarget
Order By t.VIN Ascending, t.OrderDate Descending) On _
t.VIN Equals mc.VIN Into TargetMatches = Group, _
InTMS = Count(Not t.PDSCargoItemID = 0), _
InOTA = Count(Not t.TransportItemInID.IsValueNull) _
Select Whatever = mc, Match = TargetMatches.FirstOrDefault, Result = ri, InTMS, InOTA
我正在努力与Group Join和Into TargetMatches = Group pieces:
Group Join t In (From t In claimTarget Order By t.VIN Ascending, t.OrderDate Descending) On _
t.VIN Equals mc.VIN Into TargetMatches = Group
答案 0 :(得分:1)
您正在努力解决的问题似乎是针对VIN上的claimTargets进行了left outer join。
因此,对于r.Items中具有匹配VIN的mcs中的每一行,它会从claimTarget中找到具有相同VIN的最新(by OrderDate)项,如果有的话
查询返回一个包含5个字段的匿名对象: