Take over a project in half way, it’s base on asp.net MVC and use LinQ for data access layer.
When I try to add a new function in one class, and use LinQ to get one row data from a table, get below error:
The null value cannot be assigned to a member with type System.Boolean which is a non-nullable value type.
the LinQ is very simple:
var CouponCode = (
from r in tb_CouponMasters
where r.szCouponName == couponCode && r.nStoreFK == storeId
When I go to the class found that one property is bool type from one column of table, but no exception control if the data is null, and in dbml schema layer it was defined as Bit NOT NULL for Server Data Type. That mean someone changed the table after this project was built.
Solution is change Nullable from False to True, save and build the project again.