如何在字段中返回空值的记录 [英] How to return the record with null value in a field
本文介绍了如何在字段中返回空值的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在已奖励字段中返回空值的记录。我尝试编码为
I want to return records with null value in the field 'Awarded'. I tried to code as
public int ReadAllPendingApplicationByBorough(int AcademicYearID, int BoroughID)
{
int recordCount = 0;
recordCount = (from p in currentContext.SignOffs
join q in currentContext.Schools on p.SchoolID equals q.SchoolID
where q.BoroughID == BoroughID
&& p.Submitted == true
&& p.Awarded.ToString()==null
&& p.AcademicYearID==AcademicYearID
select p).Count();
return recordCount;
}
但仍然没有返回正确的价值
当我在SQl服务器中查询相同时仍然无法正常工作,如果我将获奖的条件更改为获奖为空,则表明工作正常。但我无法给出获奖的条件,就像它显示为错误信息一样。
任何人都可以帮我编码这个
but still it is not returning the correct value
when I queried the same in SQl server still it is not working and if I change condition for Awarded as 'Awarded is null' it is working fine. But I couldn't give the condition for Awarded in the same way as it shows as error message for that.
Can anyone help me to code this
推荐答案
尝试
Try
&& p.Awarded.ToString()==DBNull.Value
而不是。
尝试删除ToString
调用:
Try removing theToString
call:
&& p.Awarded == null
这篇关于如何在字段中返回空值的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文