I'm trying to get nHibernate to join the name of the structure that is stored in separate table into the structure POCO object.
The database looks something like this:
+-----------+ +------------+ +-----------+
| Structure | | Texts | | Languages |
+===========+ +============+ +===========+
| Id | | Id | | Id |
| NameId | | LanguageId | | Name |
| FieldA | +------------+ +-----------+
| FieldB |
+-----------+
I would like the POCO object to look like the following:
public class Structure
{
public Structure()
{
}
public long Id
{
get { return name; }
set { name = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
public string FieldA
{
get { return name; }
set { name = value; }
}
public string FieldB
{
get { return name; }
set { name = value; }
}
private long id;
private string name;
private string fieldA;
private string fieldB;
}
So what I am trying to achive is to get the name property of the POCO object joined in from the Texts table with the following criteria:
Texts.Id=Structure.NameId AND Texts.Id=CurrentLanguageId
(CurrentLanguageId would be stored in the application and mapped into nHibernate)
So how to map this join in nHibernate and how to inject a property from the application into the join.