How do I order by and group by in a Linq query?
I tried..
Dim iPerson = From lqPersons In objPersons Where Len(lqPersons.Person) > 0 Group lqPersons By key = lqPersons.Name Into Group Order By Group descending Select Group, key
For Each i In iPerson
tmp = tmp & vbNewLine & i.key & ", " & i.Group.Count
Next
The above works if I remove the Order By Group Descending
claus, but with it, I get an error on the Next
statement..
At least one object must implement IComparable.
My query is to obtain a list of the people in my class/object with how many times their name is used as an item of the class/object.
I.e.
Joe, 4 | James, 5 | Mike, 4
Does anyone have any ideas what I'm doing wrong?