I have an object that represents a Deparment. Department can contain many Employee and one SubDepartment. Employee can contain many Employee for Subordinates. How can I represent this relationship with Fluent NHibernate. The Domain class looks like this:
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
}
And My Database Tables look likes :
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.
How to create fluent nhibernate mapping for Select and Insert a Data to the table.