Say I have a list, List<Foo> SomeList
, and Foo
is a class that has two properties, Bar
and Baz
.
Is there a LINQ query that will allow me to select all the items of type Foo
that share the same value for Bar
, so they can be processed together?
Something like:
foreach (List<Foo> foos in SomeList.SelectBy (x => x.Bar))
{
// process foos
}
so that all the Foo
items with Bar = 0
are processed first, then those with Bar
set to 1, and so on and so forth.
Can this be done easily, or do I need to write that functionality myself?