ServiceStack.OrmLite 继承映射

ServiceStack.OrmLite inheritance mapping

ServiceStack.OrmLite是否支持继承映射?

喜欢 DevExpress XPO: Inheritance Mapping or nHibernate Inheritance.

例如 (c#):

public abstract class EventBase
{
   public string Name { get;set; }
}
public class NormalEvent: EventBase
{
   public string A { get;set; }
}
public class SuperDuppaEvent:EventBase
{
   public string B { get;set; }
}

在数据库中存在一个 table 'EventBase' 以及来自 'NormalEvent'、'SuperDuppaEvent' 和 'EventBase' 的所有 Columns/Properties。

文档中存在 'AliasAttribute' 但它不起作用。

否OrmLite不支持继承映射。 OrmLite 的核心期望是每个 POCO 映射 1:1 与其代表的 RDBMS table。所以默认情况下,每个 类 都将映射到具有相同名称的 RDBMS table:

  • NormalEvent > 正常事件 table
  • SuperDuppaEvent > SuperDuppaEvent table

如果您想要不同的行为,您需要将 POCO 类 1:1 映射到您希望它在数据库中的布局方式,例如:

class NormalEvent
{
    public string A { get; set; }
    public int EventBaseId { get; set; }
}