public ActionResult NoOfLeaves()
{
string CurrentUserID = User.Identity.GetUserId();
var result = (from u in db.LeaveTypes
join s in db.LeaveDetails
on new { id = u.LeaveTypeID } equals new { id = s.LeaveTypeID}
join user in db.Users
on new { id = s.EmpID } equals new { id = user.Id }
where user.Id == CurrentUserID
select new noOfLeavesView
{
EmployeeID = user.Id,
EmployeeName = user.Name,
LeaveTypeName = u.LeaveTypeName,
Issued = u.NoOfLeaves
});
return View(result);
}
休假类型包含休假医疗等的类型。休假详细信息包含用户应用的叶子历史记录。我想知道用户申请了多少病假。
public ActionResult NoOfLeaves()
{
var result = (from u in db.LeaveTypes
join s in db.LeaveDetails
on new { id = u.LeaveTypeID } equals new { id = s.LeaveTypeID }
select new noOfLeavesView
{
LeaveTypeName = LeaveTypeId.LeaveTypeName,
Issued = u.NoOfLeaves,
Availed = (db.LeaveDetails.Where(i=>i.LeaveTypeID.Equals(s.LeaveTypeID)).Count()),
}).Distinct();
return View(result);
}
通过这种方式,我得到了所需的结果...