【问题标题】:nhibernate, How to create a Custon IUserType for the type "numeric array"nhibernate,如何为“数字数组”类型创建自定义用户类型
【发布时间】:2016-05-12 01:44:19
【问题描述】:

我的 postgresql 表中有一个 numeric[] 类型,我正在尝试使用 nhibernate 将其映射到我的类

    public class Samples {
        public virtual int SampleId { get; set; }
        public virtual double[] Spectro { get; set; }        
        public virtual int ExamId { get; set; } 
        public virtual short Num { get; set; }
}

public SamplesMap() {
            Table("samples");
            LazyLoad();
            Id(x => x.SampleId).GeneratedBy.Identity().Column("sample_id");
            Map(x => x.Spectro).Column("spectro");
            Map(x => x.ExamId).Column("exam_id").Not.Nullable();
            Map(x => x.Num).Column("num").Not.Nullable();
        }

有了这个,我得到了(Npgsql.NpgsqlException: 42804: column "spectro" is of type double precision[] but expression is of type bytea)

我知道我需要自定义类型,但我不知道如何。我见过一些自定义类型的例子,但没有像数字数组那样。

请帮帮我!

【问题讨论】:

标签: c# postgresql nhibernate


【解决方案1】:

Najera 带给我的消息来源 (github.com/daanl/Fluent-NHibernate--PostgreSQL-column-array) 就是答案!只需将字符串更改为双精度即可。

【讨论】:

  • 您可以接受您自己的答案,Stack Overflow 对此表示欢迎。但请包含帮助您解决问题的链接的相关部分。如果链接断开,仅链接的答案将变得无用。
猜你喜欢
  • 1970-01-01
  • 2013-12-01
  • 2017-04-13
  • 2011-10-09
  • 1970-01-01
  • 1970-01-01
  • 2019-05-30
  • 1970-01-01
  • 2014-06-19
相关资源
最近更新 更多