.net - How do I order by and group by in a Linq to objects query? -


how order , group in linq query?

i tried..

dim iperson = lqpersons in objpersons len(lqpersons.person) > 0 group lqpersons key = lqpersons.name group order group descending select group, key      each in iperson         tmp = tmp & vbnewline & i.key & ", " & i.group.count     next 

the above works if remove order group descending claus, it, error on next statement..

at least 1 object must implement icomparable.

my query obtain list of people in class/object how many times name used item of class/object.

i.e.

joe, 4 | james, 5 | mike, 4

does have ideas i'm doing wrong?

excuse c#, couldn't like...

objpersons.where(p=> p.person > 0).groupby(p => p.name).select(p => new { name= p.key, number = p.count()}).orderbydescending(p=> p.number); 

main idea:

  1. groupby did
  2. select new object using key (name) , counting how many in group
  3. order descending

Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -