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
Post a Comment