Вы можете расширить Group
с помощью SelectMany
:
var groupedCustomerList = userList
.GroupBy(u => u.GroupID) // Grouping
.SelectMany(group => group) // Expand groups back (flatten)
.ToList();
Что происходит:
initial: {tbl1, tbl1, tbl2, tbl3, tbl1, tbl4, tbl2}
after GroupBy: {Key = "1", {tbl1, tbl1, tbl1}},
{Key = "2", {tbl2, tbl2}},
{Key = "3", {tbl3}},
{Key = "4", {tbl4}},
after SelectMany: {tbl1, tbl1, tbl1, tbl2, tbl2, tbl3, tbl4}