tags:

views:

27

answers:

1

In my legacy database, I've got a table [Templates] with four columns for the "special instructions" 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?

+1  A: 

That is more naturally mapped as a component - http://nhforge.org/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; }
}
Lachlan Roche
Thanks, you're right, I shouldn't give something a type of List unless it is supposed to behave like one.
Jonny Cundall