-4
無法弄清楚如何在VB中的LINQ中編寫此查詢。如何在VB.Net中編寫此查詢LINQ
SELECT
createdon, SUM(LoggedTime), SUM(cost)
FROM TimeLedger
WHERE userid = v_UserId and YEAR(createdon) = v_Year
GROUP BY createdon
ORDER BY createdon DESC;
這是我的第一次努力
result = (from p in db.TimeLedgers where p.userid=v_userid and year(p.createdon)= p_year group by createdon order by createdon select cost).sum()
你在'訂單留出了'Descending'根據',用於訪問年份成員的VB(和C#)語法是'.Year',並且您應該在'Group'之後'Order By',因爲您不應該指望保持原始順序的Group。 – NetMage