var temp = from x in
(from y in TraceNumberList
join z in packageLsit on y.Key equals z.TrackingNo
select new
{
OrderNumber = y.Value,
TraceNumber = y.Key,
TraceTime = z.LastPackageTrace.TraceTime,
Trace = z.LastPackageTrace.Trace
})
group x by x.OrderNumber into g
let xtime = g.Max(x => x.TraceTime)
select g.FirstOrDefault(x => x.TraceTime == xtime);