简体   繁体   中英

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 want the records having false value in isAssigned column . When I try fetching it using my LINQ query I get the following error:

System.Data.SqlTypes.SqlNullValueException: 'Data is Null. This method or property cannot be called on Null values.'

This error occurs only when I try to fetch rows with false value in isAssigned column.

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. Made the date column as not null and the problem is solved. Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM