Categories
asp.net-mvc c# entity-framework linq sql

Check schedule overlap using LINQ

I Have a table like below

SL  Classroom  Weekday  StartTime  EndTime
-- --------- ------- --------- --------
1 ADMN-100 Friday 01:00:00 02:00:00
2 ADMN-100 Friday 02:00:00 03:00:00
3 ADMN-100 Monday 01:00:00 02:00:00
4 LAB-501 Monday 01:00:00 02:00:00

Using LINQ, how can I check if a time overlap is occurring?

I failed doing below,

bool check = true;
check = db.Classrooms.Any(x => x.Classroom.Equals(roomNo)
&& x.Weekday.Equals(weekDay)
&& x.StartTime < startsAt
&& x.EndTime > startsAt);