首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >转换成每个混凝土类表后的错误列数

转换成每个混凝土类表后的错误列数
EN

Stack Overflow用户
提问于 2013-08-13 10:56:38
回答 1查看 385关注 0票数 1

我已经采取了一个工作实体类和地图,并转换为使用基类。

由于这样做,我得到了"NHibernate.MappingException: property映射有错误的列数:“在user类中的任何复合用户类型上:

代码语言:javascript
复制
public SubModel : TreeNodeBase
{
   string Name { get; set; }
   Quantity Gross { get; set; }
}

public class SubModelMapping : SubclassMap<SubModel>
{
    public SubModelMapping()
    {
        Table("SubModel");

        Abstract();

        Map(x => x.Name); //normal types are fine

        Map(x => x.Gross) //this causes the error
            .LazyLoad()
            .CustomType<QuantityCompositeUserType>()
            .Columns.Clear()
            .Columns.Add("Gross_Scalar", "Gross_UoM");
    }
}

public class TreeNodeBaseMapping : ClassMap<TreeNodeBase>
{
    public TreeNodeBaseMapping()
    {
        //We are using Table Per Concrete Class inheritance

        // indicates that this class is the base
        // one for the TPC inheritance strategy and that 
        // the values of its properties should
        // be united with the values of derived classes
        UseUnionSubclassForInheritanceMapping();

        Id(x => x.Id);
        Map(x => x.Level);
        References(n => n.Parent)
            .LazyLoad()
            .Nullable();
        HasMany(n => n.Children)
            .KeyColumn("Parent_id")
            .Where(x => x.Parent.Id == x.Id)
            .LazyLoad();
    }
}
  • 在我转到TPCC继承之前工作过。
  • 如果删除任何复合用户类型映射,则工作。

知道是什么导致的吗?如果可能相关,可以提供QuantityCompositeUserType

编辑 SQL它创建:

代码语言:javascript
复制
create table SubModel(
   Id UNIQUEIDENTIFIER not null,
   Name TEXT,
   Gross_Scalar NUMERIC,
   primary key (Id)
)

您可以看到,预期的列Gross_UoM完全缺失。

如果这是普通的ClassMap而不是SubclassMap

代码语言:javascript
复制
create table Transactions (
   Id UNIQUEIDENTIFIER not null,
   Name TEXT,
   Gross_Scalar NUMERIC,
   Gross_UoM TEXT,
   primary key (Id)
)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-14 13:23:33

这似乎是个老毛病。

检查并从github构建源代码,修复了这个问题。

nuget版本从2012年6月开始,因此非常过时。我会问开发人员什么时候他们计划发布这样的补丁给nuget,并会张贴他们在这里说的话。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18207274

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档