开发者

Select query with Datetime? and Datetime doesn't work!

开发者 https://www.devze.com 2022-12-18 09:38 出处:网络
Here what I would like to do: var groups = from g in Group.All() where g.FirstDay < startDate && (g.LastDay == null || g.LastDay >= startDate)

Here what I would like to do:

var groups = 
  from g in Group.All() 
  where g.FirstDay < startDate && (g.LastDay == null || g.LastDay >= startDate)
  select g;

FirstDate is a dateTime and LastDate is a nullable datetime. I'm getting an "Sys开发者_JAVA技巧tem.InvalidOperationException: The operators of the 'LessThan' do not correspond with parameters from the method 'op_LessThan'."

This query works with small modifications (and completely different results!) like:

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;

I already changed the order of the expressions, but it do not change the results...

Any ideas?!

Thanks!!! I am getting crazy with this small query!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号