Recently I have a task which need to do as following description, my question is that is LINQ capable to do it?
Say I have a set of data, each consists of three columns: a(int),b(int),c(int)
What I want to do is to group these data by a and b, and for each distinct pair (a,b), store their corresponding c into separate list.
For example: If I have a set of data(a,b,c) {(1,3,5), (2,4,6), (1,3,7), (2,4,8)},
I want to split the data into two separate list, each contains c's value:
List 1 (a=1,b=3) : [5,7]
List 2 (a=2,b=4) : [6,8]
What I have tried is to group / order by the data by (a,b), and got a sorted list of data, I can of course use any loop to iterate the set of data and split them into several list, just wondering if there is a more beautiful solution, like using a single LINQ query?
Any suggetion is pleased! Thanks :)