Orderby after groupby
Options
I have a query that I'm using to group the records.
tblAgentActivities
.Where (aa => aa.StartDate >= DateTime.Today)
.OrderBy (aa => aa.AgentActivityID)
.GroupBy (aa => aa.tblUser.FullName)
.OrderBy (aa => aa.Key)
When I run this, I get a bunch of nested tables grouped by "FullName", which is what I want. But I want to be able to sort those tables by AgentActivityID, which I can't.
tblAgentActivities
.Where (aa => aa.StartDate >= DateTime.Today)
.OrderBy (aa => aa.AgentActivityID)
.GroupBy (aa => aa.tblUser.FullName)
.OrderBy (aa => aa.Key)
When I run this, I get a bunch of nested tables grouped by "FullName", which is what I want. But I want to be able to sort those tables by AgentActivityID, which I can't.
Comments
-
Sorry, forgot the actual question..
Is there a way to sort the grouped tables? -
Thanks, that's actually me. I'm still wondering if there's a way to use the native functionality of linqpad rather than side-stepping it.
-
Yes, there is. See my answer on SO.
-
Joe, great answer, and you are 100% correct, I'm using linq to entities.