I'm trying to group by on result of group by. I need to group by on column "a" of result q from a dapper query and then I need to further group by on result of this grouping. How can I do this or how do I access the "key' and its elements of each grouped by value?
The first groupby returns "GroupedEnumerable" of my class. There are two elements in it (since there are only two unique values for column a but that can change) and then each element has a key and then Result. I need to further group by some value within the result of each key.
var result = q.Groupby(x => x.a);
Let's say the Model/Class looks like this
public class MyClass
{
public string a { get; set; }
public string b { get; set; }
public string c { get; set; }
public string d { get; set; }
public string e { get; set; }
}
I get a list of objects from a dapper query.
var v = repository.getResult(id);
Now I group by on a.
var t= v.Groupby(x => x.a);
Now in resultview there are multiple elements and each element contains some properties of original class like (a,b,c,d, and so on) I need to group on say c now.
I guess I'm just interested in knowing what kind of result set does this result in. I don't have to use linq, I can just use good old loop if I knew how to get to inner elements.