流利的nhibernate约定:设置多态性模式 [英] fluent nhibernate convention : setting polymorphism mode

查看:102
本文介绍了流利的nhibernate约定:设置多态性模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能创建一个简单的约定来修改一个类的多态性模式,如果有一个联接子类?

Is it possible to create a simple convention to modify the polymorphism mode of a class, if there is a joined-subclass ?

执行此操作:

public class EntityMap : ClassMap<EntityBase>
{
    public EntityMap()
    {
        Polymorphism.Explicit();
    }
}

使用IClassConvention不起作用,因为Polymorphism属性是只读的:

but inside a convention. Using IClassConvention doesn't work, as the Polymorphism property is read only :

public class TestConvention : IClassConvention
{
    public void Apply(IClassInstance instance)
    {
        // read only property !
        instance.Polymorphism = Polymorphism.Explicit;
    }
}


推荐答案



Try

instance.Polymorphism.Explicit();

这篇关于流利的nhibernate约定:设置多态性模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆