通过计数与群体连接

如何在 linq (vb.net)中编写这个查询?

 select B.Name
from Company B
group by B.Name
having COUNT(1) > 1
174146 次浏览

像这样:

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);

对于任何希望在 vb 中做这件事的人(因为我是,而且找不到任何东西)

From c In db.Company
Select c.Name Group By Name Into Group
Where Group.Count > 1

下面的解决方案可能对你有帮助。

var unmanagedDownloadcountwithfilter = from count in unmanagedDownloadCount.Where(d =>d.downloaddate >= startDate && d.downloaddate <= endDate)
group count by count.unmanagedassetregistryid into grouped
where grouped.Count() > request.Download
select new
{
UnmanagedAssetRegistryID = grouped.Key,
Count = grouped.Count()
};