title: NHibernate - Many To One - NHibernate.LazyInitializationException - Could not initialize proxy
body: <p>I am getting this exception when I attempt to access an object that is stored in a property of my domain object. I have done some research and still do not understand why I am getting this error. </p>
  
  <p>I have a very basic repository in which I am creating a session and then using a ICriteria query to fetch the first record from the list of results. My Connection domain object has one to many relationship mapped to Server. Why does the session not include the server as a proxy when it fetches the Connection object? I'm not very familiar session managment with NHibernate.</p>
  
  <p>Here is my implementation:</p>
  
  <p>Domain obj:</p>
  
  <pre><code>public class Connection {
  
  public virtual int Id { get; private set; }
  
  
  public virtual string FullName { get; set; }
  
  
  public virtual string Email { get; set; }
  
  
  public virtual string NickName { get; set; }
  
  
  public virtual string Alternative { get; set; }
  
  
  public virtual bool IsInvisible { get; set; }
  
  
  public virtual Server CurrentServer { get; set; }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>  public Connection GetConnection()
      {
          using (ISession session = NHibernateHelper.OpenSession())
          {
              ICriteria crit = session.CreateCriteria(typeof(Connection));
              crit.SetMaxResults(1);
              IList&lt;Connection&gt; connection = crit.List&lt;Connection&gt;();
              return connection[0];
  
          }
      }
  </code></pre>
  
  <p>The above will successfully return a Connection object. However accessing the CurrentServer property with throw the exception. It is/was my assumption that NHibernate was aware of the relationship that this object has with 'CurrentServer' and would therefore load that object, lazily, when requested. Can someone tell me where I was led astray?</p>
  
  <p>Thanks!</p>