我创建了一个SQL查询,如下所示:
SELECT s.FullName, s.[Id], COUNT(t.[User]) AS Records
FROM dbo.AspNetUsers s INNER JOIN dbo.PBBuilds t
ON s.Id = t.[User]
GROUP BY t.[User], s.[FullName], s.[Id]
ORDER BY COUNT(t.[User]) DESC
我试图将其转换为LINQ查询,这就是我有多远:
Dim results = From H In context.Users
Join C In context.PBBuilds On H.Id Equals C.User
Group By C.User Into
有人可以提供建议吗。
答案 0 :(得分:1)
尝试此查询 - (尽管做出相应的更改)
$(".tbody").load(location.href+" .tbody > *",function(){
$.getScript("js/highlight.min.js");
});
答案 1 :(得分:0)
尝试代码
var results = From U In context.AspNetUsers
Join P In context.PBBuilds On U.Id Equals P.User
Group new {U,P} By new { P.User, U.FullName } Into g
select new {
FullName = g.FirstOrDefault().U.FullName,
ID = g.FirstOrDefault().U.Id,
Records = g.Count()
}).OrderByDescending(c=>c.Records).ToList();