【发布时间】:2023-03-03 01:23:01
【问题描述】:
我正在尝试将我的一些存储过程转换为 Linq,但遇到以下 Transact-Sql 语句的问题:
Select
Year(p.StartDate) As Year,
(Select Sum(t.Units) From Time t Where Year(t.TransactionDate) = Year(p.StartDate)) As Hours,
(Select Sum(i.Price) From Invoice i Where Year(i.CreatedDate) = Year(p.StartDate)) As Invoices
From
Period p
Group By
Year(p.StartDate)
Order By
Year(p.StartDate)
我正在与 LinqPad 合作,试图解决这个问题......任何帮助将不胜感激!
进展
到目前为止,我有以下内容......只是想弄清楚如何转换子查询:
from p in Periods
group p by p.StartDate.Year into g
orderby g.Key
select new
{
g.Key,
}
【问题讨论】:
-
您能解释一下您遇到了什么样的问题/错误吗?
-
我正在尝试转换这个 Linq ......这就是我正在努力的地方......主要是子查询。
标签: database linq linq-to-sql tsql