基本问题:如何在Fluent NHibernate中创建双向一对多地图?
细节:
我有一个有很多孩子的父对象.在我的情况下,孩子没有父母,所以在数据库中,我想外键的母体有NOT NULL约束是没有意义的.我从Fluent NHibernate映射自动生成我的数据库.
我的父母有很多子对象,如下所示:
public class Summary
{
public int id {get; protected set;}
public IList<Detail> Details {get; protected set;}
}
public class Detail
{
public int id {get; protected set;}
public string ItemName {get; set;}
/* public Summary Owner {get; protected set;} */ //I think this might be needed for bidirectional mapping?
}
Run Code Online (Sandbox Code Playgroud)
这是我开始的映射:
public class SummaryMap : ClassMap<Summary>
{
public SummaryMap()
{
Id(x => x.ID);
HasMany<Detail>(x => x.Details);
}
}
public class DetailMap : …Run Code Online (Sandbox Code Playgroud)