c# - Is there any elegant way in LINQ to bucket a collection into a set of lists based on a property -
i have collection of cars. want bucket separate lists property of car . . .lets brand.
so if have collection of ford, chevy, bmw, etc, want seperate list each of buckets.
something like:
ienumberable<car> mycarcollection = getcollection(); list<ienumerable<car>> buckets = mycarcollection.bucketby(r=>r.brand)
does exist or need "manually" through loops
return mycarcollection.groupby(r => r.brand);
Comments
Post a Comment