同じタイプの親を持つ次のクラスがあります。
public class Unit
{
public virtual int UnitKey { get; set; }
public virtual string UnitName { get; set; }
public virtual string UnitType { get; set; }
public virtual Unit Parent { get; set; }
public virtual User UnitLeader { get; set; }
}
データベースには Unit というテーブルがあります
Unit_Key (int)
Unit_Name (varchar)
Unit_Type (varchar)
Parent_Key (varchar)
User_Key (int)
そして、これがマッピングクラスの方法です。
internal class UnitMapping : ClassMapping<Unit>
{
public UnitMapping()
{
Id(x => x.UnitKey, map =>
{
map.Column("Unit_Key");
map.Generator(Generators.Assigned);
});
Property(x => x.UnitName, map =>
{
map.Column("Unit_Name");
map.NotNullable(true);
});
Property(x => x.UnitType, map =>
{
map.Column("Unit_Type"); map.NotNullable(true);
});
ManyToOne(x => x.UnitLeader, map =>
{
map.Column("User_Key"); map.Cascade(Cascade.None);
});
}
}
同じテーブルにある親 (同じクラスの型) をマップするにはどうすればよいですか。
ありがとう