我有一个代表部门的对象。部门可以包含多个员工和一个子部门。Employee 可以包含多个 Employee for 下属。我如何用 Fluent NHibernate 表示这种关系。Domain 类如下所示:
public class Department : Entitybase
{
public int Id;
public string DepartmentName;
public List<Employee> Employees;
public Department SubDepartment;
}
public class Employee : EntityBase
{
public int Id;
public string Name;
public List<Employee> Subordinates
}
我的数据库表看起来像:
Department Table
Id: int
SubDepartmentId : int // a sub department id
DepartmentName : string
Employee Table
Id : int
SuperviserId : int // A Superviser Id
Name : string
DepartmentId : int // a department id that contain this employee.
如何为 Select 和 Insert a Data 创建流利的 nhibernate 映射到表。