0

我正在尝试根据表中的值做出决定。我很难得到一个答案。这就是我所尝试的。

var open = from a in db.checkinhours
           where a.location == "Canyon" && a.day == day && a.opentime <= time && a.closetime >= time
           select a;

if (open == null)
{
    return RedirectToAction("Closed");
}   

我只需要知道该行是否基于给定的一组标准存在,但我无法弄清楚。

提前致谢

4

2 回答 2

0

open 将只是一个表达式树。你可能想做

if(open.FirstOrDefault() != null)
{
   return RedirectToAction("Closed");
}
于 2013-08-14T21:58:24.803 回答
0
    if (!db.checkinhours.Any(a => 
a.location == "Canyon" && 
a.day == day 
&& a.opentime <= time 
&& a.closetime >= time))
       return RedirectToAction("Closed");
于 2013-08-14T22:00:25.060 回答