Fluent-NHibernate递归映射

Fluent-NHibernate递归映射,nhibernate,recursion,fluent,Nhibernate,Recursion,Fluent,我有一个表示位置的对象。位置可以包含其他位置。我如何用Fluent NHibernate表示这种关系。该类如下所示: public class Location : EntityBase { #region Properties public string LocationName { get; set; } public Location ParentLocation { get; private set; } private List<Location

我有一个表示位置的对象。位置可以包含其他位置。我如何用Fluent NHibernate表示这种关系。该类如下所示:

public class Location : EntityBase
{
    #region Properties
    public string LocationName { get; set; }
    public Location ParentLocation { get; private set; }

    private List<Location> _locations = new List<Location>();
    public IEnumerable<Location> Locations
    {
        get { return _locations; }
    }

    private List<Device> _devices = new List<Device>();
    public IEnumerable<Device> Devices
    {
        get { return _devices; }
    }

    #endregion
    //Other logic omitted
}
公共类位置:EntityBase
{
#区域属性
公共字符串位置名称{get;set;}
公共位置ParentLocation{get;private set;}
私有列表_locations=新列表();
公共可数地点
{
获取{return\u locations;}
}
私有列表_设备=新列表();
公共可数设备
{
获取{return\u devices;}
}
#端区
//省略其他逻辑
}

谢谢。

可以获取私有字段

HasManyToMany(Member.Reveal<Location>("_locations"))
hasmanytomy(成员显示(“\u位置”))

可以获取私有字段

HasManyToMany(Member.Reveal<Location>("_locations"))
hasmanytomy(成员显示(“\u位置”))

您当前的映射是什么?为什么HasManyToMany(map=>map.Locations)不起作用?@Paco:属性位置需要一个setter来处理Fluent NHibernate。您当前的映射是什么?为什么HasManyToMany(map=>map.Locations)不起作用?@Paco:属性位置需要一个setter来处理Fluent NHibernate。