zoukankan      html  css  js  c++  java
  • [NHibernate]Nhibernate如何映射sqlserver中image字段

    概述

    有这样一个需求需要管理企业内网的信息,包括图标和链接。考虑到图标也不是很大所以就将图片直接保存在数据库中了。

    但是用到Nhibernate,如何映射呢?

    Table 5.5. Large Object Mapping Types

    NHibernate Type.NET TypeDatabase TypeRemarks
    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[]字节数组。

    总结

    记录项目中遇到的问题,记录点点滴滴。

  • 相关阅读:
    关于http请求头的一些事
    关于http抓取字段的一些事
    多线程的一些事
    正则的一些事
    出现问题集及解决方案
    常见的正则
    Http常见状态码
    list&tuple简记
    函数式编程--高阶函数--sorted
    函数式编程--高阶函数--filter
  • 原文地址:https://www.cnblogs.com/wolf-sun/p/3956802.html
Copyright © 2011-2022 走看看