I have a class that represents a shift that employee's can work:
public class Shift {
public int Id { get; set;}
public DateTime Start {get;set;}
public DateTime End { get; set;}
public DayOfWeek Day { get; set;}
}
And say I have a list of these shifts for a single employee:
List<Shift> myShifts;
I know I can get group the shifts by day with the following linq statement:
var shiftsByDay = from a in myShift
group a by a.Day;
My question: For each day, how can I get all the shifts that overlap, in separate groups, without double counting?
An overlapping shift is one where either the start or end times overlap with another shifts start or end times.
I'd love to be able to do this with linq if at all possible.