Search code examples
nhibernatenhlambdaextensions

'OR' in NHibernate Lambda Extensions


How can I union two criteria with an OR statement?

For example I want to get Employee which has null in Birthday field OR value of this field is less than someDate. How should I rewrite this code:

var query = DetachedCriteria.For<Employee>()
    .Add(SqlExpression.IsNull<Employee>(p => p.Birthday))
    .Add<Employee>(emp => emp.Birthday.Value < someDate);

Solution

  • You need to use Disjunction()