chrismeek
chrismeek

Reputation: 81

NHibernate Mapping from multiple tables

Consider the following table structure...

Appointment
-----------
ID integer
Description nvarchar
StatusID smallint

Status
------
ID smallint
DisplayText nvarchar

Now, for good or for evil, we want this situation to map to a class that looks like this

class Appointment
{  
    public int ID {g;s;}
    public string Description { g;s; }
    public string Status { g; private s; }
}

I.e. we want to pull the normalised status display text straight into the entity.

Upvotes: 3

Views: 1341

Answers (2)

Tim Scott
Tim Scott

Reputation: 15205

Don't create an entity class. Use an enum and EnumStringType as shown here. This is exactly what you want I think.

Upvotes: 2

chrismeek
chrismeek

Reputation: 81

The obvious answer is to create a Status entity and make the appointment class have a reference to that and map it in the normal way.

Upvotes: 4

Related Questions