I have an employee table:
Employee
{
Name
EmployeeId -pk
PositionId -fk
}
The positionId maps to the position table:
Position
{
PositionId -pk
ReportsToId
PositionName
PositionDescription
}
The ReportsToId field is a position Id for that positions manager.
I would like to select out an employee, their position and their managers details.
How would this be done using NHibernate's Mapping.ByCode.
The ReportsToId field is not a key field. From what I've read online, this seems to affect the mapping...
The mapping in this case would by 5.1.10. many-to-one with a feature called
property-ref
:So, the Position class should have ID and property
ReportsToId
The Employee C# class would have this property:
And the mapping of the Employee's property
ManagerPosition
, would be (see: Adam Bar, Mapping-by-Code - ManyToOne)