Saturday, 20 April 2013

How to find a intersecting appointment in calendar using Linq Q

intersectingAppointmentItems = appointmentItems.Select(c => c as object)
                                           .Where(c => (c.StartDate <= item.StartDate && (c.EndDate >= item.EndDate || c.EndDate > item.StartDate)) ||
                                           (item.StartDate <= c.StartDate && (item.EndDate >= c.EndDate || item.EndDate > c.StartDate)))&&
(c => (c.StartTime <= item.StartTime && (c.EndTime >= item.EndTime || c.Time > item.StartTime)) ||
                                           (item.StartTime <= c.StartTime && (item.EndTime >= c.EndTime || item.EndTime > c.StartTime)));