开发者

NHibernate string property length attribute

So I have an NHibernate mapping file with the following property:

<property name="FullName" column="FullName" type="string" not-null="true" />

If I set the length="50" for example, NHibernate will t开发者_开发百科runcate the string when inserting into the database. If I remove the length property, that database throws the exception like it should; saying that it cannot insert the record. Is this normal behavior? If so, what is the purpose of the length property. Perhaps I've configured NHibernate incorrectly or am not appreciating the situation. Any thoughts/ideas would be great.


Length property is used to create a database from the model/mappings when you are using schema exporter.

If you are looking for string length validation during persistence, take a look at the NHibernate.Validator project.

http://nhforge.org/blogs/nhibernate/archive/2009/05/01/nhibernate-validator.aspx

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜