开发者

How do I make an IgnoreProperty convention in fluent nhibernate?

public class MyObjectMap : IAutoMappingOverride<MyObject>
{
    public void Override(AutoMapping<MyObject> mapping)
    {
        mapping.IgnoreProperty(x => x.InterfaceProperty);
    }
}

I am currently doing this in every map... how can I make this into a convention? I am adding conventions like so:

    private Action<IConventionFinder> GetConventions()
    {
        return c =>
        {
            c.Add<ForeignKeyConvention>();
            c.Add<HasManyConvention>();
            c.Add<HasManyToManyC开发者_如何学JAVAonvention>();
            c.Add<ManyToManyTableNameConvention>();
            c.Add<PrimaryKeyConvention>();
            c.Add<ReferenceConvention>();
            c.Add<TableNameConvention>();
        };
    }


I think this is not something related to Convention,however it is subject to Mapping Overriding, try this:

public class AutoMapDefaultConfig : DefaultAutomappingConfiguration
{
    public override bool ShouldMap(FluentNHibernate.Member member)
    {
        if (member.Name == "InterfaceProperty")
            return false;
        return base.ShouldMap(member);

    }
}

i haven't try this actually, but I think it may help,and notice that the DefaultAutomappingConfiguration is in Fluent-NHibernate V1.1

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜