Reputation: 958
I have 2 tables like this: (Please note the non-standard db schema naming)
table T_Pen
TP_ID
TP_PrimaryColorID
TP_SecondaryColorID
...
table E_Color
EC_ID
EC_ColorName
...
And I want to create a mapping of the 2 tables to a domain object Pen
using Fluent NHibernate.
class Pen
{
PenID;
PrimaryColorName;
SecondaryColorName;
...
}
How can I do that?
Upvotes: 1
Views: 408
Reputation: 18794
I don't think you would be able to Insert/Update anymore if you were to only reference the Name.
You could create a view of PenColour or hide the actual reference in your pen class and only expose the Name property.
Upvotes: 1
Reputation: 1359
class Pen
{
int PenID;
Color PrimaryColor;
Color SecondaryColor;
}
class Color
{
int ColorID;
string ColorName;
}
class ColorMap
{
Id(x => x.ColorID);
Map(x => x.ColorName);
}
class PenMap
{
Id(x => x.PenID);
References(x => x.PrimaryColor).Column("TP_PrimaryColorID");
References(x => x.SecondaryColor).Column("TP_SecondaryColorID");
}
Upvotes: 0