- How to get an average time from an Datetime field via the Entity Framework ?
- How to subtract one Date from another ?
I am thinking of something like:
ObjectQuery<Visit> visits = myentitys.Visits;
var uQuery =
from visit in visits
group visit by visit.ArrivalTime.Value.Day into g
select new
{
Day = g.Key,
Hours = g.Average(visit => (visit.LeaveTime.Value - visit.ArrivalTime.Value).TotalMinutes)
};
to get the average residence time of an visitor grouped by Day.