Linq con el grupo teniendo cuenta


¿Cómo escribo esta consulta en linq (vb.net)?

 select B.Name
 from Company B
 group by B.Name
 having COUNT(1) > 1
Author: Fernando, 2010-01-16

2 answers

Así:

from c in db.Company
group c by c.Name into grp
where grp.Count() > 1
select grp.Key

O, usando la sintaxis del método:

Company
    .GroupBy(c => c.Name)
    .Where(grp => grp.Count() > 1)
    .Select(grp => grp.Key);
 229
Author: Thomas Levesque,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-08-21 21:49:03

Para cualquiera que busque hacer esto en vb (como yo estaba y no pude encontrar nada)

From c In db.Company 
Select c.Name Group By Name Into Group 
Where Group.Count > 1
 5
Author: Michael Andrews,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-07-21 22:28:12