0

I have this SQL query which gives the output as 15.but, when I converted the same query in Linq,it gives an output as 72.

select sum(DATEDIFF(day,LeaveBreakup.StartDate,LeaveBreakup.EndDate)+1) as totalNoOfDays from LeaveApplication
inner join Employee
on LeaveApplication.Employee=Employee.Id
inner join Team
on Employee.Team=Team.Id
inner join LeaveBreakup
on LeaveApplication.Id=LeaveBreakup.LeaveApplication
inner join LeaveTypeDetail
on LeaveBreakup.LeaveType=LeaveTypeDetail.LeaveType
where Employee.Team=5 and LeaveStatus!=0 and LeaveBreakup.StartDate between '01-01-2016' and '01-31-2016' and LeaveBreakup.WhichHalf=0

var Stafflist = (from LApp in db.LeaveApplications
                             join Emp in db.Employees
                            on LApp.Employee equals Emp.Id
                             join Tm in db.Teams
                             on Emp.Team equals Tm.Id
                             join LBrk in db.LeaveBreakups
                            on LApp.Id equals LBrk.LeaveApplication
                             join LTD in db.LeaveTypeDetails
                             on LBrk.LeaveType equals LTD.LeaveType
                             where Emp.Team == 5 && LApp.LeaveStatus != 0 && LBrk.StartDate >= d1 && LBrk.StartDate <= d2 && LBrk.WhichHalf == 0
                              select DbFunctions.DiffMinutes(LBrk.StartDate, LBrk.EndDate)).Sum() / 60;
akash
  • 173
  • 1
  • 14

0 Answers0