转换为“每个混凝土类别的表”后的列数错误

本文关键字:错误 混凝土 转换 | 更新日期: 2023-09-27 18:27:24

我已经获取了一个工作实体类和映射,并转换为使用基类。

由于这样做,我在派生类中的任何组合用户类型上都得到了"NHibernate.MappingException:属性映射的列数错误:"

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:

create table SubModel(
   Id UNIQUEIDENTIFIER not null,
   Name TEXT,
   Gross_Scalar NUMERIC,
   primary key (Id)
)

您可以看到所需的列Gross_UoM完全缺失。

而如果这是一个常规的ClassMap,而不是SubclassMap

create table Transactions (
   Id UNIQUEIDENTIFIER not null,
   Name TEXT,
   Gross_Scalar NUMERIC,
   Gross_UoM TEXT,
   primary key (Id)
)

转换为“每个混凝土类别的表”后的列数错误

这似乎是一个旧错误。

从github检查并构建源代码解决了这个问题。

nuget版本的日期是2012年6月,所以非常过时。我会问开发人员什么时候计划向nuget发布这样的修复程序,并在这里发布他们所说的。