开发者

FluentNHibernate Mixing Fluent and Auto Mappings

Is there a clean way to mix fluent mappings wit开发者_如何学编程h automappings? Ideally, I'd like to say "if I don't have a ClassMap for a domain object, then automap it". Is there a recommended approach? I'd rather not use attributes on my business objects that are data access related (ex: [UseAutoMapping]).


Yes - check out IAutoMappingOverride

Basically, any mappings which override the Automapping behaviour need to implement this interface.

e.g.

public class MyClassMap : IAutoMappingOverride<MyClass>
{
    public void Override(AutoMapping<MyClass> mapping)
    {
        mapping.IgnoreProperty(host => host.HostName);
        mapping.Table("BobsHardware");
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜