Group by and order by

Posted by Simon Thompson on Stack Overflow See other posts from Stack Overflow or by Simon Thompson
Published on 2010-03-24T15:59:21Z Indexed on 2010/03/24 16:03 UTC
Read the original article Hit count: 482

Filed under:
|
|

using LINQ to NHibernate does anybody know how to use group by and order by in the same expression. I am having to execute the group by into a list and then order this, seem that I am missing soemthing here ???

Example:-

Private function LoadStats(...) ...
  Dim StatRepos As DataAccess.StatsExtraction_vwRepository = New DataAccess.StatsExtraction_vwRepository

  return (From x In StatRepos.GetAnswers(Question, Questionnaire) _
              Group x By xData = x.Data Into Count() _
              Select New ChartData 
                   With {.TheData = xData, 
                         .TheValue = xData.Count}
         ).ToList.OrderBy(Function(x) x.TheData)

End Sub

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about vb.net