Group into a dictionary of elements

It will be more efficient to replace:

gdc => gdc.ToList()[0].groupID

with:

gdc => gdc.Key

Other than that, it looks like I would have done.

Alternately, if you are okay with extension methods over LINQ (I personally prefer them), it can be shortened further still with:

var t = data.GroupBy(data => data.groupID).ToDictionary(gdc => gdc.Key, gdc => gdc.ToList());

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)