public class MyObjectMap : IAutoMappingOverride<MyObject>
{
public void Override(AutoMapping<MyObject> mapping)
{
mapping.IgnoreProperty(x => x.InterfaceProperty);
}
}
我目前正在每张地图中执行此操作...如何将其转化为惯例?我正在添加如下惯例:
private Action<IConventionFinder> GetConventions()
{
return c =>
{
c.Add<ForeignKeyConvention>();
c.Add<HasManyConvention>();
c.Add<HasManyToManyConvention>();
c.Add<ManyToManyTableNameConvention>();
c.Add<PrimaryKeyConvention>();
c.Add<ReferenceConvention>();
c.Add<TableNameConvention>();
};
}
答案 0 :(得分:1)
我认为这不是与“公约”相关的内容,但它受制于“覆盖覆盖”,请尝试以下方法:
public class AutoMapDefaultConfig : DefaultAutomappingConfiguration
{
public override bool ShouldMap(FluentNHibernate.Member member)
{
if (member.Name == "InterfaceProperty")
return false;
return base.ShouldMap(member);
}
}
我实际上没有尝试过,但我认为它可能有所帮助,并注意到 DefaultAutomappingConfiguration 在Fluent-NHibernate V1.1中