2009-07-23 87 views
0

我有两个类:NHibernate的父/子一个一对一的映射

public class Code 
{ 
    public virtual Guid CodeId { get; set; } 
    public virtual string CodeValue { get; set; } 
    public virtual Guid EntryId { get; set; } 
} 

public class Entry 
{ 
    public virtual Guid EntryId { get; set; } 
    public virtual string FirstName { get; set; } 
    public virtual string LastName { get; set; } 
    public virtual string Address { get; set; } 
    public virtual string Address2 { get; set; } 
    public virtual string City { get; set; } 
    public virtual string State { get; set; } 
    public virtual string Zip { get; set; } 
    public virtual string Email { get; set; } 
    public virtual string Phone { get; set; } 
    public virtual string IpAddress { get; set; } 
    public virtual DateTime BirthDate { get; set; } 
    public virtual DateTime Created { get; set; } 
    public virtual bool OptIn { get; set; } 
    public virtual Code Code { get; set; } 
} 

我想NHibernate的自动加载/保存条目对象的代码子属性(它可以为空,并通过链接代码表中的外键“EntryId”),但我无法弄清楚映射。 hibernate.org上的文档现在没有加载,所以有人可以用下面的映射指出我正确的方向吗?

<class name="Code" table="Codes"> 
    <id name="CodeId"> 
     <generator class="guid.comb"/> 
    </id> 
    <property name="CodeValue" /> 
    <property name="EntryId" 
    </class> 

    <class name="Entry" table="Entries"> 
    <id name="EntryId"> 
     <generator class="guid.comb"/> 
    </id> 
    <property name="FirstName" /> 
    <property name="LastName" /> 
    <property name="Address" /> 
    <property name="Address2" /> 
    <property name="City" /> 
    <property name="State" /> 
    <property name="Zip" /> 
    <property name="Email" /> 
    <property name="Phone" /> 
    <property name="BirthDate" /> 
    <property name="OptIn" /> 
    <property name="IpAddress" /> 
    <property name="Created" />  
    </class> 
+0

http://www.nhforge.org/doc/nh/en/index.html;) – asgerhallas 2009-07-23 20:29:18

回答