0
我有這個簡單的SQL查詢:組,總和,加入Linq中
select c.LastName, Sum(b.Debit)- Sum(b.Credit) as OpenBalance from Balance as b
inner join Job as j on (b.Job = j.ID)
inner join Client as c on (j.Client = c.ID)
Group By c.LastName
,我試圖將其轉換在LINQ的工作是這樣的:
from b in Balance
join j in Job on b.Job equals j.ID
join c in Client on j.Client equals c.ID
group b by new { c.LastName } into g
select new {
Name = c.Lastname,
OpenBalance = g.Sum(t1 => t1.Credit)
}
但是當我嘗試在LINQPad運行我得到以下信息:
名稱「C」不會在 CUR存在租金背景
它突出顯示c.Lastname
在select new
聲明。
對此的任何幫助將不勝感激。 謝謝。