If you want Min and Max value for each ID in the list, then you have to group by ID
and the get MAX and Min accordingly like:
var query = yourList.GroupBy(r=> r.ID)
.Select (grp => new
{
ID = grp.Key,
Min = grp.Min(t=> t.Col1),
Max = grp.Max(t=> t.Col2)
});
Use Enumerable.Max method to calculate maximum like:
var max = yourList.Max(r=> r.Col1);
Use Enumerable.Min method to calculate minimum on a field like:
var min = yourList.Min(r=> r.Col2);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…