What's the most efficient way to convert an IEnumerable<T>
to an IDictionary<U, IEnumerable<T>>
Where U is, for example a Guid, for which the information is held in a property of T.
Basically, this creates a dictionary of lists where all items in the original list are grouped based on a value in a property within 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;
Whereby listOfObj
contains objects that have many different, but sometimes overlapping values for the UID property.
Using LINQ: