简体   繁体   中英

ServiceStack.OrmLite inheritance mapping

Does ServiceStack.OrmLite support inheritance mapping?

Like DevExpress XPO: Inheritance Mapping or nHibernate Inheritance .

For example (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; }
}

In database exist one table 'EventBase' with all Columns/Properties from 'NormalEvent', 'SuperDuppaEvent' and from 'EventBase' too.

In the documentation exist the 'AliasAttribute' but it doesn't work.

No OrmLite does not support inheritance mapping. It's a core expectation in OrmLite that each POCO maps 1:1 with the RDBMS table it represents. So by default each of your classes will map to an RDBMS table with the same name:

  • NormalEvent > NormalEvent table
  • SuperDuppaEvent > SuperDuppaEvent table

If you want different behavior you'd need to map the POCO classes 1:1 with how you want it laid out in the database, eg:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM