fluent nhibernate - storing and retrieving three classes in/from one table

Posted by Will I Am on Stack Overflow See other posts from Stack Overflow or by Will I Am
Published on 2010-05-20T04:40:34Z Indexed on 2010/05/20 4:50 UTC
Read the original article Hit count: 156

Filed under:

Noob question.

I have this situation where I have these objects:

class Address
{      
   string Street;
   string City;
   ...
}

class User
{
   string UserID;
   Address BillingAddress;
   Address MailingAddress;
   ...
}

What is the proper way of storing this data using (fluent) nHibernate? I could use a separate Address table and create a reference, but they are 1:1 relationships so I don't really want to incur the overhead of a join. Ideally I would store this as a single flat record.

So, my question is, what is the proper way of storing an instance of class 'User' in such a way that it stores its contents and also the two addresses as a single record? My knowledge is failing me on how I can store this information in such a way that the two Address records get different column names (e.g. BillingAddress_Street and MailingAddress_Street, for example), and also how to read a record back into a User instance.

© Stack Overflow or respective owner

Related posts about fluent-nhibernate