nhibernate父/子一对一映射

nhibernate父/子一对一映射,nhibernate,foreign-key-relationship,Nhibernate,Foreign Key Relationship,我有两门课: 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 v

我有两门课:

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自动加载/保存Entry对象的Code-child属性,该属性可以为null,并由Codes表中的外键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>

我相信这篇文章很好地描述了这些可能性:


您不需要模拟双向性,但这很容易忽略。

;这是一个链接到一个现在还没有关闭的。第5.1.11节。这让我想到了一些使用ICollection并建立一对多关系的方法,但我仍然不确定如何使用子表上的外键进行一对一的操作。