我正在使用 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);
[...]
关于如何解决这个问题的任何想法都可以?