title: NHibernate 4 upgrade - Cannot simultaneously fetch multiple bags
body: <p>I tried to upgrade NH 3.3.1.4000 to the latest version NH 4.0.2.4000 and I had an issue with FetchMany and ThenFetchMany.</p>
  
  <p>In this post I learned that this old functionality is no longer valid, <a href="https://stackoverflow.com/questions/25450581/breaking-changes-with-nhibernate-4-upgrade">Breaking changes with NHibernate 4 upgrade</a>.</p>
  
  <p>What is the correct way to do this kind of fetching on the new NH version?</p>
  
  <p>Code Example:</p>
  
  <pre><code>var IdsList = new List { /* Some Ids */ };
  session.Query&lt;A&gt;()
  .FetchMany(x=&gt;x.B_ObjectsList)
  .ThanFetchMany(x=&gt;x.C_ObjectsList)
  .Where(x=&gt;IdsList.Contains(x=&gt;x.Id))
  .ToList();
  </code></pre>
  
  <p>Classes:</p>
  
  <pre><code>Public Class A
  {
      public int Id {get;set;}
      public IList&lt;B&gt; B_ObjectsList{get;set;}
  }
  
  Public Class B
  {
      public int Id {get;set;}
      public IList&lt;C&gt; C_ObjectsList {get;set;}
  }
  
  Public Class C
  {
      public int Id {get;set;}
  }
  </code></pre>
  
  <p>Mapping:</p>
  
  <pre><code>&lt;class name="A" table="A"&gt;
  &lt;id name="Id" type="int" column="Id" unsaved-value="0"&gt;
    &lt;generator class="identity" /&gt;
  &lt;/id&gt;
  &lt;bag name="B" table="B" inverse="false" lazy="true"
  cascade="all-delete-orphan"&gt;
  &lt;/class&gt;
  
  &lt;class name="B" table="B"&gt;
  &lt;id name="Id" type="int" column="Id" unsaved-value="0"&gt;
    &lt;generator class="identity" /&gt;
  &lt;/id&gt;
  &lt;bag name="C" table="C" inverse="false" lazy="true"
  cascade="all-delete-orphan"&gt;
  &lt;/class&gt;
  
  
  &lt;class name="C" table="C"&gt;
  &lt;id name="Id" type="int" column="Id" unsaved-value="0"&gt;
    &lt;generator class="identity" /&gt;
  &lt;/id&gt;
  &lt;/class&gt;
  </code></pre>