title: Subquery in Linq to NHibernate
body: <p>I have a query by Linq in NHibernate 3.1:</p>
  
  <pre><code>public IList&lt;Person&gt; Search()
  {
      var sub_q = SessionInstance.Query&lt;Person&gt;().Where(x =&gt; x.Id &lt; 6).Select(x =&gt; x.Id);
  
      var q = SessionInstance.Query&lt;Person&gt;();
      q = q.Where(x =&gt; sub_q.Contains(x.Id));
  
      return q.ToList&lt;Person&gt;();
  }
  </code></pre>
  
  <p>Id column is primary key in Database
  This sub-query does not work. Count of my query with sub-query equals by count of my query without use sub-query.</p>
  
  <p>Count of my query whit sub-query    : 52 //Correct count is 5</p>
  
  <p>Count of my query without sub-query : 52</p>
  
  <p>Why? </p>
  
  <p><strong>Updated:</strong>
  My problem resolved by rename <code>x</code> variable in sub_q to <code>xx</code></p>
  
  <pre><code> var sub_q = SessionInstance.Query&lt;Person&gt;().Where(xx =&gt; xx.Id &lt; 6).Select(xx =&gt; xx.Id);
  </code></pre>
  
  <p>Why?</p>