我正在使用NHibernate和ConfORM来映射我的域实体。
假设以下课程:
public class Event {
public virtual Guid Id { get; set; }
public virtual string Title { get; set; }
public virtual bool Active { get; set; }
}
public class EventA : Event {
public virtual string PropertyA { get; set; }
}
public class EventB : Event {
public virtual string PropertyB { get; set; }
}
我需要不重复派生类中的NHibernate表字段,但是使用基类,如图所示。
我的ConfORM设置:
var domainAssembly = typeof(Event).Assembly;
var domainEntities = from t in domainAssembly.GetTypes() where t==typeof(Event) select t;
var orm = new ObjectRelationalMapper();
orm.Patterns.Sets.Add(new UseSetWhenGenericCollectionPattern());
orm.Patterns.PoidStrategies.Add(new ConfOrm.Patterns.IdentityPoidPattern());
orm.TablePerConcreteClass(domainEntities);
var patternsAppliers = new CoolPatternsAppliersHolder(orm);
var mapper = new Mapper(orm, patternsAppliers);
[...]
关于如何处理问题的任何想法都可以吗?
答案 0 :(得分:0)
与orm.TablePerConcreteClass(domainEntities);
交换orm.TablePerClass(domainEntities);
,这将创建
Event
-----
PK | Id
EventA
-----
PK,FK | EventId
因为EventS中没有必要单独的Id列