所以,让我说我有一个班级:
public class Person
{
public DateTime DateOfBirth { get; set; }
public string Name { get; set; }
public Person Parent
{
get
{
return Session.QueryOver<Person>().Where(x =>
x.FamilyId == FamilyId &&
x.FamilyJoinOrder == null
).SingleOrDefault();
}
}
public IList<Person> Children { get; set; }
public int? FamilyId { get; set; }
public int? FamilyJoinOrder { get; set; }
}
我已将其映射为:
public class PersonMap
{
public PersonMap()
{
CompositeId()
.KeyProperty(x => x.DateOfBirth)
.KeyProperty(x => x.Name);
Map(x => x.FamilyId).Nullable();
Map(x => x.FamilyJoinOrder).Nullable();
HasMany(x => x.Children)
.Table("Person")
.PropertyRef("FamilyId")
.Where("FamilyJoinOrder > 0")
.ReadOnly()
.Fetch.Subselect();
}
}
我的问题是儿童收藏品不起作用,它总是空着的。
为澄清条件,这里是:
如何映射孩子以使其真正起作用? 它甚至可能吗?