in NHibernate, map 4 similar columns to list<string>
In my legacy database, I've got a table [Templates] with four columns for the "special instruct开发者_如何学JAVAions" on a shipment:
.....|Spx_1|Spx_2|Spx_3|Spx_4|....
.....| | | | |.....
I want to map this to a List in my class:
public class Template
{
..
public virtual List<string> SpecialInstructions
{
get;
set;
}
...
}
How do I do this with (xml) nhibernate?
That is more naturally mapped as a component - http://nhibernate.info/doc/nh/en/index.html#components
<class name="Template">
<component name="SpecialInstructions">
<property name="Line1" column="spx_1"/>
<property name="Line2" column="spx_2"/>
<property name="Line3" column="spx_3"/>
<property name="Line4" column="spx_4"/>
</component>
<class>
public class Template
{
public Instructions SpecialInstructions { get; set; }
}
public class Instructions
{
public string Line1 { get; set; }
public string Line2 { get; set; }
public string Line3 { get; set; }
public string Line4 { get; set; }
}
精彩评论