title: Problems with HasMany, Lazy loading and session scopes
body: <p>I have a console application that uses NHibernate and ActiveRecord.</p>
  
  <p>I am using the following detached criteria:  </p>
  
  <pre><code>DetachedCriteria criteria = DetachedCriteria.For&lt;ServiceOrder&gt;();
  
              criteria.Add(Restrictions.Lt("End", DateTime.Today.AddDays(3)));
              criteria.Add(new Disjunction()
                              .Add(Restrictions.IsNull("StopReason"))
                              .Add(Restrictions.Eq("StopReason", ServiceStopReason.Worthiness)));
  
              criteria.Add(new Disjunction()
                              .Add(Restrictions.IsNull("StopDate"))
                              .Add(Restrictions.EqProperty("StopDate", "End")));
  </code></pre>
  
  <p>And I am invoking the fetching using ActiveRecordMediator's FindAll() method.<br>
  In my model I have this property:  </p>
  
  <pre><code>[HasMany(Lazy = true)]
  public virtual ISet&lt;ServiceOrder&gt; ServiceOrders
  {
      get { return serviceOrders; }
      set { serviceOrders = value; }
  }
  </code></pre>
  
  <p>Which I'm trying to access to in the following Linq query:  </p>
  
  <pre><code>from serviceOrder in serviceOrderDataService.GetServiceOrdersWithEndOfEntitlement()
       let accountGetService = serviceOrder.AccountGetService
       where accountGetService != null
       let serviceOrders = accountGetService.ServiceOrders
       where serviceOrders != null &amp;&amp; serviceOrders.Count != 0
       let isFutureServiceOrder = (from accountGetServiceServiceOrder in serviceOrders
                                        where serviceOrder.Start.HasValue
                                        &amp;&amp; accountGetServiceServiceOrder.End.HasValue
                                        &amp;&amp; serviceOrder.Start &gt; accountGetServiceServiceOrder.End
                                        select accountGetServiceServiceOrder).Any()
       where !isFutureServiceOrder
       select serviceOrder;
  </code></pre>
  
  <p>But I am getting the following exception:  </p>
  
  <blockquote>
    <p>Initializing[Danel.Nursing.Model.AccountService#61786367-e8da-4929-b91b-a7497cf7db10]-failed
    to lazily initialize a collection of
    role:
    Danel.Nursing.Model.AccountService.ServiceOrders,
    no session or session was closed</p>
  </blockquote>
  
  <p>Does this makes any sense? How do I solve it?</p>