views:

314

answers:

2

I have below classes. How can I write mapping document for MainBranch.Id column. I have no branch table in database, just want to use branchId for MAINBRANCHCODE. Any Idea?

public class Bundle
        {
            public virtual Decimal Id { get; set; }       
            public virtual BundleEntranceInformation Information { get; set; } 
        }
    public class BundleEntranceInformation
        {
            public virtual Branch MainBranch { get; set; }      
        }
    public class Branch
        {
            public virtual short Id { get; set; }       
        }

My mapping document:

<class name="PromissoryNotes.Server.Data.Bundle, PromissoryNotes.Server.Data" table="BUNDLE" lazy="true">
    <id name="Id" column="ID" type="Decimal">
      <generator class="increment" />
    </id>   
    <property name="Information.MainBranch.Id" column="MAINBRANCHCODE" type="short"></property>

  </class>
+1  A: 

Use a component mapping

<class name="BundleEntranceInformation">
  <component name="MainBranch">
    <property name="Id" column="MAINBRANCHCODE"/>
  </component>
</class>
Jan Willem B
yes you are right, I found it, I need to use component but not like this. Thanks for idea. Answer is as below :)
NetSide
+2  A: 

Here is the answer :)

<component name="Information">
   <component name="MainBranch">
     <property name="Id" column="MAINBRANCHCODE"/>
   </component>
</component  >
NetSide

related questions