查询两个时段中的交集数据
给定查询区间 [startDate, endDate],返回所有与之有交集的记录(被包含、包含、左交、右交都算)。
DateTime startDate = DateTime.Now.AddDays(-2);
DateTime endDate = DateTime.Now.AddDays(1);
List<T> list = ORM.Get<T>(it => it.Where(o =>
(o.StartDate >= startDate && o.StartDate <= endDate) // 起点落在查询区间内
|| (o.StartDate <= startDate && o.EndDate >= endDate) // 完全包含查询区间
|| (o.EndDate >= startDate && o.EndDate <= endDate) // 终点落在查询区间内
));