开发者

how do you translate a space value in a database field to a null in .NET with Fluent NHibernate?

开发者 https://www.devze.com 2022-12-25 16:24 出处:网络
I am working with a legacy database that stores \"blank\" values as a single space.Is there a way with Fluent NHibernate, either by way of a convention or mapping override, that I can translate this \

I am working with a legacy database that stores "blank" values as a single space. Is there a way with Fluent NHibernate, either by way of a convention or mapping override, that I can translate this "blank" value as a .NET null? (I know that I will need to save nulls to this database as a single space still but I will use an save event listener for that)开发者_开发技巧.


You should use a custom implementation of IUserType for this, not a listener. Here's one example of many examples available on the web. James Gregory wrote a good article on how to implement IUserTypes using a Fluent NHibernate conventions.

0

精彩评论

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