title: Passing null values to guid column in nhibernate c#
body: <p>I am stuck in problem and not getting correct way or solution that how can I handle this. The problem is that I am creating a criteria query in which we pass property id as a parameter. The type of property id is guid. When property id have values then it is working fine but when it is null then it crash.</p>
  
  <p>I have requirement that when property id have value then filter records come according to property id and when property id is null then it filter records comes whose property id is null.</p>
  
  <p>I had tried this links <a href="https://stackoverflow.com/questions/211436/nullable-guid">Nullable GUID</a></p>
  
  <p>but it will give another exception which is type mismatch exception.</p>
  
  <p>Here my NHibernate code which I am using </p>
  
  <pre><code> var invoiceList =
       Session.CreateCriteria&lt;tARInvoice&gt;("inv")
              .Add(Restrictions.Eq("inv.fPropertyID",
                                   propertyId == null ?  (object)DBNull.Value : propertyId.Value))   
              .List&lt;tARInvoice&gt;()
  </code></pre>
  
  <p>I am using c# and NHibernate version 3.1.</p>