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.