How to get first record in each group using Linq

var result = input.GroupBy(x => x.F1, (key,g) => g.OrderBy(e => e.F2).First());

Leave a Comment