如何在linq(vb.net)中编写此查询?
select B.Name
from Company B
group by B.Name
having COUNT(1) > 1
最佳答案
像这样:
from c in db.Company
group c by c.Name into grp
where grp.Count() > 1
select grp.Key
或者,使用方法语法:
Company
.GroupBy(c => c.Name)
.Where(grp => grp.Count() > 1)
.Select(grp => grp.Key);
关于linq - Linq与组通过计数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2078736/