转:NHibernate和SqlImage

 

开发中遇到一个问题SqlServer的Image类型影射为byte[]时截断了数据,变成8k,查了下NH文档,

Table 5.5. Large Object Mapping Types

NHibernate Type .NET Type Database Type Remarks
StringClob System.String DbType.String type="StringClob" must be specified. Entire field is read into memory.
BinaryBlob System.Byte[] DbType.Binary type="BinaryBlob" must be specified. Entire field is read into memory.
Serializable Any System.Object that is marked with SerializableAttribute. DbType.Binary type="Serializable" should be specified. This is the fallback type if no NHibernate Type can be found for the Property.
解决如下

原hbm.xml

         <property   name="NH_FileContent" type="byte[]">
             <column name="FileContent" length="2147483647" sql-type="image" not-null="false"/>
         </property>
改为
         <property   name="NH_FileContent" type="BinaryBlob">
             <column name="FileContent" length="2147483647" sql-type="image" not-null="false"/>
         </property>

.net中的类型不用改

 

此内容来自http://hi.baidu.com/zhanglin34/blog/item/03ac5e9558f6514cd0135e39.html

posted @ 2011-02-23 20:42  江水  阅读(423)  评论(0编辑  收藏  举报
友情链接:『MY 163 Bolg』  『BlueIdea』  『YoBo』