title: NHibernate Criteria Find by Id
body: <p>I have 2 entities:</p>
  
  <pre><code>public class Authority : Entity
  {
      [NotNull, NotEmpty]
      public virtual string Name { get; set; }
  
      [NotNull]
      public virtual AuthorityType Type { get; set; }
  
  }
  
  public class AuthorityType : Entity
  {
      [NotNull, NotEmpty]
      public virtual string Name { get; set; }
  
      public virtual string Description { get; set; }
  }
  </code></pre>
  
  <p>Now I wish to find all authorities from repository by type. I tried doing it like this:</p>
  
  <pre><code>    public IList&lt;Authority&gt; GetAuthoritiesByType(int id)
      {
          ICriteria criteria = Session.CreateCriteria(typeof (Authority));
          criteria.Add(Restrictions.Eq("Type.Id", id));
          IList&lt;Authority&gt; authorities = criteria.List&lt;Authority&gt;();
          return authorities;            
      }
  </code></pre>
  
  <p>However, I'm getting an error that something is wrong with the SQL ("could not execute query". The innerexception is following: {"Invalid column name 'TypeFk'.\r\nInvalid column name 'TypeFk'."}</p>
  
  <p>Any advice ? Any other approach ?</p>
  
  <p>Best wishes,
  Andrew</p>