views:

548

answers:

2

I have an Employee class with a Name property of class Name and a Contact property of type Contact. The Name class has two string properties: FirstName and LastName and the Contact class has properties like PhoneNumber and EmailAddress.

All of the data is found in one table and assume that it cannot be changed. What would my maps look like so I can load an Employee based on id and populate the Contact and Name properties with their appropriate values? Or is this even possible?

public class Employee
{       
    //Constructor ommitted.

    public virtual Name Name { get; set; }      
    public virtual Contact ContactInfo { get; set; }
}

public class Name
{       
    // Constructor omitted.

    public string FirstName { get; set; }
    public string LastName { get; set; }
}

The Employee table has the following columns: EmployeeId, FirstName, LastName, plus various contact information.

Thanks!

+2  A: 

use component mapping... more details here:

http://www.hibernate.org/hib_docs/nhibernate/html/components.html

StackUnderflow
+1  A: 

I think I have found what I'm looking for at http://wiki.fluentnhibernate.org/show/StandardMappingComponents and http://blog.jagregory.com/2009/01/19/fluent-nhibernate-auto-mapping-components/

Thanks for your input as well!

related questions