0
如何通過多列組來自不同表的到來,終於總結量列如何通過多列組聯接使用LINQ
var result = _employeeDAL.GetList(db =>
from es in db.Set<EmployeeSchedule>()
join est in db.Set<EmployeeSalaryType>() on est.Employee_Id equals es.Employee_Id
join et in db.Set<EmployeeType>() on est.Employee_Salary_Id equals et.Employee_Salary_Id
where es.Status == "JOINED" && es.JoinedDate.Year == 2017
select new
{
EmployeeName = es.EmployeeName
,Amount = est.Amount ///----------> SUM THIS
,EmployeeType = et.EmployeeType
});
這裏就是我試圖
var result = _employeeDAL.GetList(db =>
from es in db.Set<EmployeeSchedule>()
join est in db.Set<EmployeeSalaryType>() on est.Employee_Id equals es.Employee_Id
join et in db.Set<EmployeeType>() on est.Employee_Salary_Id equals et.Employee_Salary_Id
group new { es, est, et } by new { es.EmployeeName, et.EmployeeType } into grp
where es.Status == "JOINED" && es.JoinedDate.Year == 2017
select new
{
EmployeeName = es.EmployeeName
,Amount = grp.Sum(g=>g.est.Amount)
,EmployeeType = et.EmployeeType
});
那麼,是什麼問題? – octavioccl
導致超時,所以只是檢查是否有其他優化的方法來拉大數據 – Kiran