【问题标题】:FluentNHibernate CustomType("Binary") MappingExceptionFluentNHibernate CustomType("Binary") MappingException
【发布时间】:2011-02-17 10:34:13
【问题描述】:

我在使用 NuGet(包版本:1.1.1.694)和 NHibernate 3.0 GA 上可用的最新 FluentNHibernate 构建映射实体时遇到问题

我想要达到的是 sql type: binary(64) with FluentNHibernate 以一种与数据库无关的方式(我不想使用 CustomSqlType)。

默认值是我不想要的 varbinary(64)。小写的“二进制”也会导致这种情况。

我的映射代码:

this.Map(x => x.PasswordHash)
    .CustomType("Binary")
    .Length(64)
    .Not.Nullable();

在 NHibernate 映射 XML 文件中给出:

<property name="PasswordHash" type="Binary">
  <column name="PasswordHash" length="64" not-null="true" />
</property>

生成架构的异常: 无法加载二进制类型。 System.TypeLoadException:无法加载二进制类型。可能原因:未指定程序集名称。

在 NHibernate.Util.ReflectHelper.TypeFromAssembly(AssemblyQualifiedTypeName 名称,布尔 throwOnError)

另一方面,CustomType("StringClob") 有效。有什么我想念的吗? 有没有办法让 FluentNHibernate .CustomType 与内置的 NHibernate 类型一起工作?

(对 AnsiChar 有用,或其他 .NET 类型和数据库类型之间的非标准映射)?

【问题讨论】:

    标签: nhibernate fluent-nhibernate


    【解决方案1】:

    我相信你必须改变sql-type,而不是type(流利的语法可能是.SqlType("binary")或类似的东西)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多