標籤:style blog color 使用 ar strong for 資料 div
概述
有這樣一個需求需要管理企業內網的資訊,包括表徵圖和連結。考慮到表徵圖也不是很大所以就將圖片直接儲存在資料庫中了。
但是用到Nhibernate,如何映射呢?
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="logo" type="byte[]"> <column name="logo" length="2147483647" sql-type="image" not-null="false"/> </property>
改為
<property name="logo" type="BinaryBlob"> <column name="logo" length="2147483647" sql-type="image" not-null="false"/> </property>
c#代碼中仍然使用byte[]位元組數組。
總結
記錄項目中遇到的問題,記錄點點滴滴。
[NHibernate]Nhibernate如何映射sqlserver中image欄位