我在所有表格中都有共同的列“Id,IsActive,CreateDate”。现在我想在我的基本实体中移动“Id,IsActive,CreateDate”,并且还想创建基本映射。如何在Fluent NHibernate中实现这一目标?
答案 0 :(得分:2)
您可以像这样创建基本映射:
public class BaseMap<T> : ClassMap<T> where T : Address
{
public BaseMap()
{
Id(x => x.Id);
Map(x => x.IsActive);
Map(x => x.CreateDate);
}
}
public class SomeEntityMap: BaseMap<SomeEntity>
{
public CustomerAddressMap()
{
Table("SomeTable");
Map(x => x.SomeProperty);
}
}
public class Entity
{
public virtual Guid Id { get; set; }
public virtual bool IsActive { get; set; }
public virtual DateTime CreateDate { get; set; }
}
public class SomeEntity : Entity
{
public virtual string SomeProperty { get; set; }
}