title: QueryOver by join and add conditions by Independent if
body: <p>I have a QueryOver by JoinQueryOver In Nhibernate 3.1 </p>
  
  <p>The Person class has a association by Identity class (one-to-one)
  Code is a field of Person class and FirstName is a field of Identity class.</p>
  
  <pre><code>var q = SessionInstance.QueryOver&lt;Person&gt;()
          .Where(p =&gt; p.Code.IsLike(code,MatchMode.Start))
          .Full.JoinQueryOver(p =&gt; p.Identity);
  
  if (!String.IsNullOrEmpty(firstName))
     q = q.Where(i =&gt; i.FirstName.IsLike(firstName, MatchMode.Anywhere));
  
  return q.List&lt;Person&gt;();
  </code></pre>
  
  <p>that result is correct but, there is a problem. The search does not include items by null value for Code field in Person class.  I corrected to following query.</p>
  
  <pre><code>var q = SessionInstance.QueryOver&lt;Person&gt;()
          .Full.JoinQueryOver(p =&gt; p.Identity);
  
  if (!String.IsNullOrEmpty(Code))
     q = q.Where(i =&gt; i.Person.Code.IsLike(code, MatchMode.Start));
  
  if (!String.IsNullOrEmpty(firstName))
     q = q.Where(i =&gt; i.FirstName.IsLike(firstName, MatchMode.Anywhere));
  
  return q.List&lt;Person&gt;();
  </code></pre>
  
  <p>Now i have a runtime error by this message:</p>
  
  <blockquote>
    <p>could not resolve property: Identity.Code of: MyNameSpace.Domain.Entities.Identity</p>
  </blockquote>
  
  <p>in a query by join between two class, How can add two condition(where) by if. </p>
  
  <p><code>(if parameter != null)</code></p>