[英]Getting Data is Null error while trying to fetch record containing false value in SQL bit datatype using Linq query in C#
I am working in ASP.Net Web API .net 6. I have a column isAssigned having bit datatype in my SQL table. I am working in ASP.Net Web API .net 6. I have a column isAssigned having bit datatype in my SQL table. I want the records having false value
in isAssigned column
.我希望记录在isAssigned column
中具有false value
。 When I try fetching it using my LINQ query I get the following error:当我尝试使用我的 LINQ 查询获取它时,我收到以下错误:
System.Data.SqlTypes.SqlNullValueException: 'Data is Null. System.Data.SqlTypes.SqlNullValueException:'数据是 Null。 This method or property cannot be called on Null values.'不能对 Null 值调用此方法或属性。
This error occurs only when I try to fetch rows with false value in isAssigned
column.仅当我尝试在isAssigned
列中获取具有错误值的行时,才会发生此错误。
var record = _todoContext.OneTimeCodes.Where(x => x.IsAssigned == false).ToList();
Yes, I found it.是的,我找到了。 I had a date column with null value, hence got that error.我有一个带有 null 值的日期列,因此出现了该错误。 Made the date column as not null and the problem is solved.将日期列设置为不是 null,问题就解决了。 Thanks.谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.