Subsonic 选择带有日期时间的查询?而且Datetime不起作用!
以下是我想做的:Subsonic 选择带有日期时间的查询?而且Datetime不起作用!,subsonic,subsonic3,Subsonic,Subsonic3,以下是我想做的: var groups = from g in Group.All() where g.FirstDay < startDate && (g.LastDay == null || g.LastDay >= startDate) select g; FirstDate是日期时间,LastDate是可为空的日期时间。我得到一个System.InvalidOperationException:“LessThan”的运算符与方法“op_Les
var groups =
from g in Group.All()
where g.FirstDay < startDate && (g.LastDay == null || g.LastDay >= startDate)
select g;
FirstDate是日期时间,LastDate是可为空的日期时间。我得到一个System.InvalidOperationException:“LessThan”的运算符与方法“op_LessThan”的参数不对应
此查询只需稍作修改,结果完全不同!比如:
var groups =
from g in Group.All()
where g.LastDay == null && g.FirstDay < startDate
select g;
var groups =
from g in Group.All()
where (g.LastDay >= startDate || g.LastDay == null)
select g;
我已经更改了表达式的顺序,但它不会更改结果
有什么想法吗
谢谢!!!这个小问题让我发疯了 应为LastDay.Value(如果可为null)。否则,您将比较不兼容的类型。当我尝试.Value时,会出现一个异常,该值未实现。我试图与可为空的datetime进行比较,但错误是相同的