Linq - group by a name, but still get the id -


i'm trying find duplicates in linq particular column (the name column), wish return unique id, wish bind id display additional information row.

i've dug around on stackoverflow, can find ways of finding duplicates in fashion off:

  • by whole object
  • by particular property
  • getting number of duplicates

the closest thing find specifying "key" in group by, i'm ensure if working.

ideally i'm hoping output has id, number of duplicates.

thanks

assume have people collection:

from p in people group p p.name g select new {    name = g.key,    numberofduplicates = g.count(),    ids = g.select(x => x.id) } 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -