在SQL数据库中,如果字段为int,decimal,datetime等类型的字段存在NULL值,有linq查询报下面异常
The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type
请问怎么处理才能避免该异常?
------解决方法--------------------------------------------------------
数据库中可空的int类型、datetime类型,在Linq中分别对应Nullable <int>、Nullable <DateTime>
------解决方法--------------------------------------------------------
在数据库设计中对字段,最好加默认值。避免null的判断,同样性能也有很大的提高。
------解决方法--------------------------------------------------------
Nullable <T>.Value
http://www.cnblogs.com/lyj/archive/2008/02/24/1079551.html