IEnumerable <T> for IDictionary <U, IEnumerable <T>>
What is the most effective way to convert IEnumerable<T>
toIDictionary<U, IEnumerable<T>>
Where U is, for example, Guid, for which information is stored in property T.
Basically, this creates a dictionary of lists, where all the elements in the source list are grouped according to the value in the property of the objects.
Example
Object Definition:
class myObject
{
public Guid UID { get; set; }
// other properties
}
Start with:
IEnumerable<myObject> listOfObj;
End with:
IDictionary<Guid, IEnumerable<myObject>> dictOfLists;
The result listOfObj
contains objects that have many different but sometimes overlapping values ββfor the UID property.
+3