title: Select child collection IDs without join in nHibernate
body: <p>I want to select the primary keys of a parent's child collection in a many-to-many relationship without using a join. Due to other constraints that have been removed from this example, the querying must occur on the child level (Tag) instead of parent level (Item).</p>
  
  <pre><code>Item item = null;
  Tag tag = null;
  
  var qoTags = QueryOver.Of&lt;Tag&gt;(() =&gt; tag)
               .JoinQueryOver(x =&gt; x.Items, () =&gt; item)
               .Select(Projections.Group&lt;Item&gt;(() =&gt; item.ItemId));
  </code></pre>
  
  <p>generates</p>
  
  <pre><code>SELECT Item.ItemId
  FROM Tag 
  inner join ItemsTags on Tag.TagId  =  ItemsTags.TagId 
  inner join Item on ItemsTags.ItemId  =  Item.ItemId 
  GROUP BY Item.ItemId 
  </code></pre>
  
  <p>but ideally, the generated SQL would be:</p>
  
  <pre><code>SELECT ItemsTags.ItemId
  FROM Tag 
  inner join ItemsTags on Tag.TagId  =  ItemsTags.TagId  
  GROUP BY ItemsTags.ItemId 
  </code></pre>
  
  <p>Notice the unnecessary join is removed and the 'group by' and 'select' clauses are referencing the junction table's ID's. </p>
  
  <p>Thanks!</p>