开发中遇到一个问题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>
改为<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>
<column name="FileContent" length="2147483647" sql-type="image" not-null="false"/>
</property>
.net中的类型不用改