title: NHibernate POCO / Basics
body: <p>I've formerly used L2S and am looking at using NHib along with the Sharp Architecture on a project. I've started prototyping and come up against the first issue which i have no idea how to google for.</p>
  
  <p>Given a POCO with some simple properties, and one reference property (Category - class not shown here):</p>
  
  <pre><code>public class Post
  {
    public Post()
    {
      this.DateCreated = DateTime.Now;
    }
  
    public virtual string Title {get;set;}
    public virtual DateCreated {get;set;}
    public virtual Category {get;set;}
  }
  </code></pre>
  
  <p>This is handy if i want to say produce a summary of posts in tabular format - if i want a column named "Category" and i want to show the category title i can simply use Post.Category.Title.</p>
  
  <p>However a user creates a new post (they select a category from a drop down list or similar). They click submit, and i new up a Post object. However before i can persist the new Post, i have to retrieve an instance of the Category (by id) to assign to the Category property?</p>
  
  <p>How to get the best of both worlds? If i update the Post POCO, making the Category an int, I've made it simpler to create new instances. But harder for some rendering code which will now have to resolve the category name given the Id?</p>
  
  <p>I feel i'm missing some basic concept here? </p>
  
  <p>I know with Linq to Sql given a schema where the Post table had an integer foriegn key column named CategoryId, would generate me both the underlying table column (CategoryId) and and EntitySet which contained the foreign key row. </p>
  
  <p>How to acheive similar in NHibernate? How is this generally managed?</p>
  
  <p>Thanks</p>