Fluent NHibernate: Map List <String>

I know there are many questions on how to display a list of strings using free nHibernate. I tried all the options that I have. But still no luck.

My situation is as follows.

class BaseClass
{
    public string Name {get;set;}
}

class FirstChild : BaseClass
{
    public string Parameter{get;set;}
    public IList<string> OtherParameter {get;set;}
}

The mapping file used is as follows:

public class BaseClassMap: ClassMap<BaseClass>
{
    public BaseClassMap()
    {
        Table("BaseClass");          
        Map(x => x.Name);
        DiscriminateSubClassesOnColumn<string>("Class");
    }
}

public class FirstChildMap : SubclassMap<FirstChild>
{
    public FirstChildMap ()
    {
        Map(x => x.Parameter);
        HasMany(x => x.OtherParameter)
            .Element("OtherParameter ")
            .Table("OtherParameterTable").Cascade.AllDeleteOrphan();
    }
}

After that, when I try to save the type object FirstChild, it saves the value Nameand Parameter, but nothing happens in OtherParameterTable.

Can someone tell me where I am going wrong?

+3
source share

Source: https://habr.com/ru/post/1778103/


All Articles