Adding another answer here by someone,
(which seems to have been deleted, I was trying that approach and got it to work too).
All credit goes to that anonymous person.
source.GroupBy(x => x.Name, y=> y.Value)
.Select( result => new { Name = result.Name,
Values = result.Select(r=> r.Value).ToList() } );
The dictionary solution seems to be more intuitive as I can see all the transformations happening to generate the result.
EDIT:
Spent way too much time on this, here are 2 other ways to make this happen:-
source.GroupBy(grpKey => grpKey.Name,
elementSelector => elementSelector,
(resultSelectorName, resultSelectorValues ) => new
{
Name = resultSelectorName,
Values = resultSelectorValues.Select(v=>v.Value).ToList()
});
2)
source.GroupBy(grpKey => grpKey.Name,
elementSelector => elementSelector.Value,
(resultSelectorName, resultSelectorValue ) => new
{
Name = resultSelectorName,
Values = resultSelectorValue.ToList()
});