title: NHibernate filter grand children collection
body: <p>I have the following objects</p>
  
  <pre><code>public class Parent {
      int Id;
      Object Obj1;
      Object Obj2;
      DateTime Date1;
      IList&lt;Child&gt; Children;
  }
  
  public class Child {
      int Id;
      Parent Parent;
      IList&lt;GrandChild&gt; GrandChildren;
  }
  
  public class GrandChild {
      int Id;
      Child Child;
      DateTime Date2;
  }
  </code></pre>
  
  <p>I need to limit the GrandChild list by Date2.  I tried the following</p>
  
  <pre><code>Parent parentAlias = null;
  Child childAlias = null;
  GrandChild grandChildAlias = null;
  
  ICriterion dateCriterion = Restrictions.Where&lt;GrandChild&gt;(
      g =&gt; g.Date2.Date &gt;= fromDate &amp;&amp; g.Date2.Date &lt;= toDate
  );
  
  var query = QueryOver.Of(() =&gt; parentAlias)
      .Inner.JoinAlias(() =&gt; parentAlias.Children, () =&gt; childAlias)
      .Inner.JoinAlias(() =&gt; childAlias.GrandChildren, () =&gt; grandChildAlias, dateCriterion)
      .Where(p =&gt; p.Obj1.Id == param1 &amp;&amp; p.Obj2.Id == param2 &amp;&amp; p.Date1 == paramDate);
  
  var result = query.GetExecutableQueryOver(session).SingleOrDefault();
  </code></pre>
  
  <p>However this does not filter the grand child collection.</p>
  
  <p>Your input is greatly appreciated.</p>
  
  <p>Thank you.</p>