title: Nhibernate Criterion - select rows in table A of TypeId defined in Table B
body: <p>the title is confusing sorry, if you can think of a better one, please change it.</p>
  
  <p>I have three tables, say, bikes, owners and a relationship table (something like many to many) that defines all owners of a bike, or all bikes of an owner.</p>
  
  <p><img src="https://i.stack.imgur.com/khsXQ.png" alt="enter image description here"></p>
  
  <p>So, I want to select All bikes of OwnerId 1
  But, my mapping is like so: </p>
  
  <pre><code>BikeOwners references one Bike
  BikeOwners References one OWner
  </code></pre>
  
  <p>How do I write the criterion in nhibernate to do this? </p>
  
  <p>Right now, I am trying: </p>
  
  <pre><code>            DetachedCriteria crit = DetachedCriteria.For&lt;Bikes&gt;()
              .Add(Expression.Eq("OwnerId", _ownerId));
  </code></pre>
  
  <p>and it errors out saying there isn't any <code>OwnerId</code> in Bikes table, which I understand.. </p>
  
  <p>Hope the question is clear.. If you need any details, please ask!</p>
  
  <p><hr>
  <sup>I know I can get first get a list of all Bike id's from <code>Bike owner</code> table and then use that int array to get all bikes in <code>bikes</code> table - BUT - it is two database access and I am doing it manually, there should be a way to do this in one go, right? </p>
  
  <p>This is my plan b, if all else fails, I'll do this.</p>
  
  <p>Thanks</sup></p>