I think I've read every post on this subject but still can't seem to get this to work. I want to duplicate the following GroupBy with dynamic Linq. I've tried this Dynamic GroupBy but can't seem to get the First().
var result = mydata
.GroupBy(g => g.ID)
.Select(z => z.First())
.Select("new (ID, Field1, Field2)");
The GroupBy needs to be dynamic. I need the first row of the grouped field. So..
ID:1, Field1:W, Field2:L
ID:1, Field1:A, Field2:B
ID:2, Field1:A, Field2:B
ID:2, Field1:C, Field2:D
Should end up being:
ID:1, Field1:W, Field2:L
ID:2, Field1:A, Field2:B
OR
ID:1, Field1:A, Field2:B
ID:2, Field1:C, Field2:D