[Solved]-Is there a way to Sum SQLFunction.DateDiff inside a LINQ query?-LINQ,C#

www.appsloveworld.com/linq/200/121/is-there-a-way-to-sum-sqlfunction-datediff-inside-a-linq-query

1 Users

1 Comments

1 Highlights

0 Notes

Tags

Top Highlights

  • var timeDifArray = (from s in pe.Services join g in pe.Groups on s.GroupId equals g.GroupId join ud in pe.UserDetails on s.UserIdInCharge equals ud.UserId into ud1 from ud in ud1.DefaultIfEmpty() where allowedGroups.Contains(g.GroupId) && (!filterBySector || filter.selectedSectors.Contains(g.GroupId)) && (!filterByGroup || (s.UserIdInCharge.HasValue && members.Contains(s.UserIdInCharge.Value))) && (s.Status == (decimal)Data.Enums.ServiceStatus.Active || s.Status == (decimal)Data.Enums.ServiceStatus.Sold) && s.ServiceStartDate >= startDate && s.ServiceStartDate <= endDate group s by new Guid() into services select new { services.ServiceStartDate, services.ServiceEndDate, }).ToArray(); var timeDifs = timeDifArray.Select(x => x.ServiceEndDate.Subtract(x.ServiceEndDate)); var totalTimeDifs = timDifs.Sum(x => x.Hours);

Toughts & Comments

Arunkumar Ramakrishnan

49881

Ready to highlight and find good content?

Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.