I currently have this database table which doesn't allow null in any field, and I'm using Fluent NHibernate mapping the strings into the table. The thing is, when I try submitting an empty string in the HTTP form, the string is parsed as NULL and then saved into the database, which causes the not null constraint failure. So my question is, how can I specify saving NULL as empty string in Fluent NHibernate?
1 Answer
Either you consider null values illegal in your domain model, which means that the input layer should take care to use empty string if the submitted data contains null for technical reasons. Or if you want to allow nulls in the domain model, you should have a custom user type for NHibernate (implement IUserType) to handle the conversions between null and empty strings.