zoukankan      html  css  js  c++  java
  • NHibernate和SqlImage

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

    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="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中的类型不用改
  • 相关阅读:
    网站色彩搭配
    web前端小知识,安书整理的
    java基础
    简单android UI必会
    java学习总结
    java字符常量与字符串常量的区别
    最近的学习
    简单的ps操作
    HTTP协议概述
    ABP 学习 Setting
  • 原文地址:https://www.cnblogs.com/babietongtianta/p/3079778.html
Copyright © 2011-2022 走看看