linq 分组 ,每组取时间最新的记录

时间:2022-06-02 20:51:53

from a in HostLog
                           group a by a.HostInfoID into grp
                           let maxModifyTime = grp.Max(a => a.ModifyTime)
                           from row in grp
                           where row.ModifyTime == maxModifyTime
                           select row;