Map List using Fluent Nhibernate

2019-08-30 11:08发布

问题:

I need to map List<Int32> using Fluent Nhibernate.

Sample code:

public class ReportRequest
{
    public List<Int32> EntityIds
    {
        get { return entityIds; }
        set { entityIds = value; }
    }
}

Please guide.

Thank you!

回答1:

I have implemented it as :

public class ReportRequestMap : ClassMap<ReportRequest>
{
    public ReportRequestMap()
    {
        Id(x => x.Id).UnsavedValue(null).GeneratedBy.Native();        
        HasMany(x => x.EntityIds).Table("ReportEntities").KeyColumn("ReportRequestId").Element("EntityId").AsBag();
    }
}