将可空的DateTime与DateTime进行比较会引发错误。 [英] comparing nullable DateTime with DateTime is throwing error.
本文介绍了将可空的DateTime与DateTime进行比较会引发错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面的代码抛出异常。
Below code throwing an exception.
query = query.where(x=>x.dbo == cretiera.DateOfBirth);
其中,x.dbo是可以为空的Datetime和cretiera .DateOfBirth是DateTime。
请帮助。
where, x.dbo is nullable Datetime and cretiera.DateOfBirth is DateTime.
Please help.
推荐答案
使您的代码行如下所示:< br $>
query = query.where(x => x.dbo!= null && x.dbo == cretiera.DateOfBirth);
Make your code line as shown below :
query = query.where(x=> x.dbo != null && x.dbo == cretiera.DateOfBirth);
似乎cretiera是你的实体。对?然后在你的实体更改获得设置属性这个
公共DateTime? DateOfBirth {get;设置;}
希望它有所帮助。
Hi,
It seems that cretiera is your entity. Right? Then in your entity change get set propert to this
public DateTime? DateOfBirth {get; set;}
Hope it helps.
这篇关于将可空的DateTime与DateTime进行比较会引发错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文