我知道有一种更有效的方法可以做到这一点,使用谓词,但是相当新,我不确定如何去做。
List<HousingAssignment> list;
using (OEContext context = new OEContext())
{
var query =
from ha in context.HousingAssignments
where ((ha.BedID == bed.ID) &&
(((ha.CheckIn <= checkin) && (ha.CheckOut >= checkin)) ||
((ha.CheckIn <= checkout) && (ha.CheckOut >= checkout))))
select ha;
list = query.ToList();
}
return list.Count;