我知道这可能已经在C#中被回答了十几次,但我很难在VB.Net中找到一个简单的解决方案(其他人正在与群组进行多次联接以及所有这些其他垃圾我不会#39 ;我需要并且无法有效地过滤掉我的解决方案。)
基本上,我试图在VB.Net上将以下(简单)SQL查询写入LINQ:
Select a.ID, a.First_Name, a.Last_Name, [Count] = count(b.ID), Last_Payment = max(b.Payment_Date)
from Members a
join Payments b on a.ID = b.Member_ID
group by a.ID, a.First_Name, a.Last_Name
我已经尝试了这么远,但Visual Studio坚持在我完成输入之前搞砸了我
Dim myResult = From d In (From a In db.Members
Join b In db.Payments On a.ID Equals b.Member_Id
Group b.Payment_Date By a.ID, a.First_Name, a.Last_Name Into joke()'<< Here VS insists this is supposed to be the name of a function, and forces me to put these parenthesis no matter what
Select ID, First_Name, Last_Name, Count = joke.Count(), Last_Payment = joke.Max())
我甚至无法让我开始使用&#34; Aggregate&#34;我读过的部分我需要做Max和Count。
有关我出错的地方的任何提示?对于这么简单的事情,这让我感到沮丧了将近两个小时......
答案 0 :(得分:1)