The basics of processing linq with group

results  = mylist
.GroupBy(x =>
.Select(x =>
var myItem = x.First();
string item_aggregated = String.Join(“,”, x.Select( … );

Or, as stated here

var results = from p in persons
              group by p.PersonId into g
              select new { PersonID = g.Key, Cars = g.ToList() };

Or as a non-query expression:

var results = persons.GroupBy(p => p.PersonId, p =>,
                         (key, g) => new { PersonId = key, Cars = g.ToList() });

Basically the contents of the group (when view as an IEnumerable<T>) is a sequence of whatever values were in the projection ( in this case) present for the given key.



This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s