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.
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.
I had tried this links Nullable GUID
but it will give another exception which is type mismatch exception.
Here my NHibernate code which I am using
var invoiceList =
Session.CreateCriteria<tARInvoice>("inv")
.Add(Restrictions.Eq("inv.fPropertyID",
propertyId == null ? (object)DBNull.Value : propertyId.Value))
.List<tARInvoice>()
I am using c# and NHibernate version 3.1.