0

I'm writing a query in .NET using LinQ technology. I want get all double records from field city. If the city count is equel to 1, then i don't want to get this in my results. Only 2 or more times. Does anyone know how I must write my query?

Thanks a lot.

Jordy

Jordy
  • 661
  • 7
  • 26

1 Answers1

4
entities.GroupBy(e => e.City)
        .Where(g => g.Count() > 1)
        .Select(g => g.Key);

Query syntax

from e in entities
group e by e.City into g
where g.Count() > 1
select g.Key
Sergey Berezovskiy
  • 232,247
  • 41
  • 429
  • 459