-2
SELECT COUNT(*) as Avalied
FROM LeaveMaster as lm
JOIN LeaveSubsidary as ls
ON lm.TransMasterId = ls.TransMasterId
WHERE lm.SystemCode = 'abc123' AND lm.EmployeeCode = '0014' AND lm.Status ='Approved'
Group by ls.Leave_Type
你會如何轉換上面的SQL查詢LINQ?謝謝:)
編輯:
from p in db.PY_LeaveTransactionMasterTAB.AsEnumerable()
join e in db.PY_LeaveTransactionSubsidaryTAB.AsEnumerable() on p.LV_TransMasterId equals e.LV_TransMasterId into grp
where p.SystemCode == SysCode && p.EmployeeCode == EmpCode && p.Status == "Approved"
group grp by e.Leave_Type // This line is invalid Why?
以上是我到目前爲止已經試過,我爲什麼不能做e.Leave_Type
或什麼是做group grp by e.Leave_Type
正確的方法是什麼?
可能重複的[LINQ - 左加入,集團通過和Count(http://stackoverflow.com/questions/695506/linq-left-join-group by-and-count) – GurV
@GurV我已經看過那個鏈接,看看我編輯的部分。 –