title: How to do Sub Selects
body: <p>given the code ( this is a made up example).  Also imagine Contract and Plan have a bunch more properties on them.</p>
  
  <pre><code>class Contract
  {
     public virtual int Id {get; set}
     public virtual IList&lt;Plans&gt; {get; set;}
  }
  
  class Plan
  {
     public virtual int Id {get; set; }
  }
  
  var blah = query
      .SelectMany(contract =&gt;
       contract.Plans.Select(plan =&gt; new {ContractId = contract.Id, PlanId = plan.Id})
      .ToList();
  </code></pre>
  
  <p>NHibernate will spit the dummy with</p>
  
  <pre><code>Cannot create a LambdaExpression that retrieves the value of '[plan]' 
  from items with a structure of 'new &lt;&gt;f__AnonymousType168`2(ContractId = 
  [contract].Id, PlanId = [plan].Id)'. The item expression does not contain the
   value or it is too complex.    
  </code></pre>
  
  <p>If I retrieve a list from the database first with ToList() I can easily do this in Linq to Objects and it gives me what I'm expecting.   Is there a way to do this with Linq and Nhibernate ?  </p>
  
  <p>I mainly want to ensure I'm retrieving the minimal necessary from the DB, in my testing by prefetching from the DB then Linq to objects takes ~ a second, the equivalent SQL takes no measurable time</p>