title: How to use NHibernate's Session.Criteria with multiple foreign keys?
body: <p>I'm trying to create a query using NHibernate and searching along multiple foreign keys:</p>
  
  <p>The following code works when I'm only searching on one of the foreign keys:</p>
  
  <pre><code>            ICriteria query = Session.CreateCriteria&lt;TblTeam&gt;()
              .Add&lt;TblTeam&gt;(x =&gt; x.FldUrlSafeName == teamName)
              .CreateCriteria&lt;TblTeam&gt;(x =&gt; x.TblSportsType)
              .Add&lt;TblSportsType&gt;(x =&gt; x.FldUrlSafeName == sportsType);
  
  
          return query.UniqueResult&lt;TblTeam&gt;();
  </code></pre>
  
  <p>I need to search on two of the foreign keys so I created the following:</p>
  
  <pre><code>            ICriteria query = Session.CreateCriteria&lt;TblTeam&gt;()
              .Add&lt;TblTeam&gt;(x =&gt; x.FldUrlSafeName == teamName)
              .CreateCriteria&lt;TblTeam&gt;(x =&gt; x.TblSportsType)
              .Add&lt;TblSportsType&gt;(x =&gt; x.FldUrlSafeName == sportsType)
              .CreateCriteria&lt;TblTeam&gt;(x =&gt; x.TblSportsOrganization)
              .Add&lt;TblSportsOrganization&gt;(x =&gt; x.FldUrlSafeName == sportsOrganization);
  
          return query.UniqueResult&lt;TblTeam&gt;();
  </code></pre>
  
  <p>Unfortunately, this gives me the following error:</p>
  
  <p>"could not resolve property: TblSportsOrganization of: site.Core.TblSportsType"</p>
  
  <p>How would I have it take a "step back" as it were so I can add criteria to TblTeam and not TblSportsType?</p>