How would I map the below table schema?
Below is a simplified example of a schema I'm trying to map in NHibernate
table:
- company_details
columns:
- some details....
- co_pk (identity)
- manager_fk_person_details (foreign key to person_details pk)
- senior_manager_fk_person_details (as above)
table:
- person_details
columns:
- ex_pk (identity)
- ex_type (type = 1 or 2 when one to one and type = 3 for a collection)
- ex_fk_company_details (foreign key to company_details pk)
then the classes would be:
Code:
public class company_details
{
public virtual int Id
{
set {}
get {}
}
public virtual PersonDetails Manager
{
set {}
get {}
}
public virtual PersonDetails SeniorManager
{
set {}
get {}
}
public virtual IList<PersonDetails> Employees
{
set {}
get {}
}
}
the above is just an example that I have come up with so please execuse code or table errors.
How would I go about implementing the above as I have tried to use discriminators (for ex_type) which works for the list of employees but don't know how to do the one-to-one
Please can someone help me as I have ran out of ideas.
Thanks for any help in advance.
Code: