开发者

Can I configure NHibernate to throw exception when value in db is null?

开发者 https://www.devze.com 2023-01-23 18:14 出处:网络
I have a situation where I have a table where some of the columns are nullable, but I want my NHiber开发者_Go百科nate-based entities to expose those values as non-nullable fields. If I do this with a

I have a situation where I have a table where some of the columns are nullable, but I want my NHiber开发者_Go百科nate-based entities to expose those values as non-nullable fields. If I do this with a normal mapping, NHibernate assigns the defult value of the type to the entity's field in the case of a null value. I would like to change this behavior so that instead an exception is thrown. Is this possible?


I think you have to change your mapping and add a not-null="true" attribute.

0

精彩评论

暂无评论...
验证码 换一张
取 消