Working on a website that has Employee and Branch entities, using a database table “Employees” which also contains the branch id and branch name. I can’t change the client’s database so I need to map Employees and Branches from the same table.
I guess I need some type of distinct clause in the mapping XML to get a distinct list or set of branches from the employee table?
Is there a way I can map both classes on the same table? (Can it be done with Fluent NHibernate?)
Use components. I don’t know FluentNhibernate, but in xml, it looks like this:
It’s actually pretty straight-forward. You also do this for performance reasons, because you don’t need to join tables when there is always a branch on an employee.
Note: If all columns are null, myBranch will be null.