Some long-gone developer left the following LINQ query behind with no documentation and I'm struggling to understand what it does (and therefore if it's doing it right). Can someone help translate this, either by breaking it into pieces or providing the SQL equivalent?
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
I am struggling in particular with the Group Join and 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