How can I group sets of expressions in NHibernate? For example, I want to filter my query like so:
(ShowOnDate IS NULL OR ShowOnDate <= GETDATE()) AND (ExpirationDate IS NULL OR ExpirationDate >= GETDATE())
I can add the 4 criterions separately, but I can't figure out how to emulate the paranthesis grouping. Thanks!
EDITED to show my final solution:
result = this.Session.CreateCriteria<Model.News>()
.Add(Expression.IsNull("ExpirationDate") || Expression.Gt("ExpirationDate", DateTime.Now.Date))
.Add(Expression.IsNull("ShowOnDate") || Expression.Le("ShowOnDate", DateTime.Now.Date))
.AddOrder(new Order("SubmittedDate", true))
.List<Model.News>();