Will there be potentially more than one bar with the same name? If so, it is difficult. If not, you can simply change it to:
var grouped = from f in fooList
orderby f.SomeBar.Name ascending
group f by f.SomeBar into Group
select Group;
var bars = grouped.Select(group => group.Key);
Alternatively, if you want only one panel for the name, you can stick to the original request, but change the last bit:
var someGroup = from f in fooList
orderby f.SomeBar.Name ascending
group f by f.SomeBar.Name into Group
select Group;
var bars = someGroup.Select(group => group.First().SomeBar);
It will take the first Foo in each group and find it Bar.
source
share