【问题标题】:How to map SQL Server `varbinary(max)` field with NHibernate ByCode mapping?如何使用 NHibernate ByCode 映射映射 SQL Server `varbinary(max)` 字段?
【发布时间】:2012-04-17 22:11:44
【问题描述】:

我有一个属性类型为 byte[] 的类,我想使用新的 NHibernate ByCode 映射将其映射到 SQL Server 中的 varbinary(max) 字段。

到目前为止,使用 SchemaAction = SchemaAutoAction.Recreate 让 NH 创建架构,我最终得到以下结果(类属性名称为“Data”):

  • 如果映射没有以任何方式限定,我最终会得到一个 varbinary(8000) 字段
  • 当映射为 map.Property(x => x.Data, m => m.Length(int.MaxValue)) 时,我最终得到一个“图像”字段(根据 SQL Server 文档,下一版本的 SQL Server 将不支持该字段)
  • 当映射为 map.Property(x => x.Data, m => m.Type(TypeFactory.GetBinaryType(int.MaxValue)) 时,我最终得到一个 varbinary(8000) 字段,这似乎是错误的

我错过了什么?

【问题讨论】:

    标签: sql-server nhibernate nhibernate-mapping


    【解决方案1】:

    我遇到了同样的问题,这对我有用。

    Property(e => e.Data, m => m.Column(cm => cm.SqlType("varbinary(MAX)")));
    

    【讨论】:

      猜你喜欢
      • 2014-09-21
      • 1970-01-01
      • 2014-06-26
      • 1970-01-01
      • 1970-01-01
      • 2010-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多