Linq to SQL 与 group by
如何在 linq VB.NET 中编写此查询?
select top 15 count(1), A.Latitude, A.Longitude
from Bairro A
inner join Empresa B on B.BairroID = A.BairroID
where A.CidadeID = 4810
group by A.Latitude, A.Longitude
order by COUNT(1) desc
我达到了这个代码:
Dim TopBairros = (From A In Bairros _
Join B In New BO.Empresa().Select On B.BairroID Equals A.BairroID Group A By A.Latitude, A.Longitude Into g = Group _
Select g Distinct _
Order By g.Count Descending).Take(15)
每一行都有一个数组集合,其中包含重复的相同对象和计数。示例:
第 0 行:874 个相同对象的数组 第 1 行:由 710 个相同对象组成的数组
,依此类推...如何才能每行仅返回一个对象?
How do I write this query in linq VB.NET?
select top 15 count(1), A.Latitude, A.Longitude
from Bairro A
inner join Empresa B on B.BairroID = A.BairroID
where A.CidadeID = 4810
group by A.Latitude, A.Longitude
order by COUNT(1) desc
I reached this code:
Dim TopBairros = (From A In Bairros _
Join B In New BO.Empresa().Select On B.BairroID Equals A.BairroID Group A By A.Latitude, A.Longitude Into g = Group _
Select g Distinct _
Order By g.Count Descending).Take(15)
Each row has a array collection containing repeatly the same objects with the count number. Example:
row 0: array of 874 same objects
row 1: array of 710 same objects
and so on... How do I do to return only ONE object per row?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
Try this: