Search code examples
nhibernatelistfluent-nhibernatemapping

How to create mapping for a List<SomeNativeType> in FluentNhibernate?


I am trying to create a mapping file for the following Model using Fluent NHibernate. But, I am not sure of how to do the mapping for the List<<string>string> in the mapping file.

    public class MyClass
    {
        public virtual Guid Id { get; set; }
        public virtual string Name { get; set; }
        public virtual List<string> MagicStrings { get; set; }
    }

    public class EnvironmentMapping : ClassMap<Models.Environment>
    {
        public EnvironmentMapping()
        {
            Id(x => x.Id);
            Map(x => x.Name);
            //HasMany(x => string)  What should this be ?
        }
    }

Solution

  • I found a solution for my problem, in my situation I have to create a separate table for MyStrings and have a foreign key relation with MyClass.