Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fluent nhibernate convention : setting polymorphism mode

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

Doing this :

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

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;
    }
}
like image 358
mathieu Avatar asked Aug 03 '10 13:08

mathieu


1 Answers

Try

instance.Polymorphism.Explicit();
like image 181
Siewers Avatar answered Dec 22 '22 00:12

Siewers