How to store a non truncated varchar(max) string with NHibernate and Fluent NHibernate

风格不统一 提交于 2019-12-03 16:30:13

问题


My DB schema has a string as a varchar(max). I have read the other questions concerning setting Length to more than 4000 or 8000 so that it really generates a (n)varchar(max) in the mapping but when I use Length(10000) in my mapping class, the hbm file actually shows length="10000" and if I save an entity with more than 10000 chars, it is actually truncated to exactly 10000 chars.

I don't want any truncation.

(using NH3-alpha2 and FNH trunk)


回答1:


It would appear that this is an old problem which is now resurfacing in NHibernate 3.x builds; you can read about the workarounds here.

Note: I have updated the original link I posted as it was outdated.




回答2:


This mapping should work:

<property name="TheProperty" type="StringClob">
  <column name="TheColumn" sql-type="nvarchar(max)" />
</property>

Just look for the fluent equivalent.




回答3:


DanP's link is broken. The updated link is:

http://www.primordialcode.com/blog/post/nhibernate-prepare_sql-considerations-mapping-long-string-fields



来源:https://stackoverflow.com/questions/3701907/how-to-store-a-non-truncated-varcharmax-string-with-nhibernate-and-fluent-nhib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!