nhibernate Restrictions.Eq and null
public AbstractCriterion EqOrNull(string property, object value) {
if (value == null)
return Restrictions.IsNull(property);
return Restrictions.Eq(property, value);
}
E.g.:
session.CreateCriteria<Advertisements>()
.Add(EqOrNull(AdvertisementsProperties.City.ToString(), city));
Also see HHH-2951
session.CreateCriteria<Advertisements>()
.Add(Expression.Or(
Expression.Eq("AdvName", "Cool Advertisement"),
Expression.IsNull("AdvName"))
).List<Advertisements>();