bArithmeticExpression参数必须具有数字公共类型。
canberraTimetable = (from r in db.ShuttleTimeTables
where r.TimeTypeId == 5 && (DateTime.Today.Date + r.Time ) >= (DateTime.Today.Date + time_15)
select r.Time).ToList()
.Select(x => new SelectListItem()
{
Text = x.Value.ToString(@"hh\:mm"),
Value = x.Value.ToString(@"hh\:mm")
}).Take(3).ToList();
如果我没有DateTime.Today.Date
添加r.Time
,那么就会遇到问题。
但是当time_15 = 23:59
,然后将选择用户可用的8:00时,我不会赢得这个。所以我在同一天只向它添加DateTime.Today.Date
箭头比较。
答案 0 :(得分:0)
我解决了,我把答案放在这里希望能帮助其他人:
canberraTimetable = db.ShuttleTimeTables.Where(r => r.TimeTypeId == 5).ToList() .Where(r => (DateTime.Today.Date + r.Time) >= (DateTime.Today.Date + time_15)) .Select(x => new SelectListItem() { Text = x.Time.Value.ToString(@"hh\:mm"), Value = x.Time.Value.ToString(@"hh\:mm") }).Take(3).ToList();