public class AdminUser
{
public virtual int Id { get; set; }
public virtual string UserName { get; set; }
public virtual string Password { get; set; }
public virtual bool IsLocked { get; set; }
public virtual AdminUser Creator { get; set; }
public virtual DateTime CreationDate { get; set; }
}
public class AdminUserMapping : ClassMap<AdminUser>
{
public AdminUserMapping()
{
Id(c => c.Id).GeneratedBy.Native();
Map(c => c.UserName).Not.Nullable();
Map(c => c.Password).Not.Nullable();
Map(c => c.IsLocked).Not.Nullable();
Map(c => c.CreationDate).Not.Nullable();
//HasOne<AdminUser>(... ?)
}
}
嗨,我上面有类,我想为同一类的“Creator”属性创建一对一的映射
我该怎么做?
答案 0 :(得分:1)
试试这个:
References(x => x.Creator);
确保您的桌面上有一个名为Creator_Id的列。如果不这样做,您可以使用:
References(x => x.Creator).Column("YourColumnName")