Do you have an idea how to write the following code nicer/shorter :) I need to check if the field form form is not empty and then add criterion to the query, thanks :)
AbstractCriterion restrictions = null;
if (model.DateFrom != null)
AddRestriction(ref restrictions,
Restrictions.Ge(Projections.Property<Invoice>(x => x.DateIn), model.DateForm));
if (model.DateTo != null)
AddRestriction(ref restrictions,
Restrictions.Le(Projections.Property<Invoice>(x => x.DateIn), model.DateTo));
if (!string.IsNullOrEmpty(model.Prop1))
AddRestriction(ref restrictions,
Restrictions.Eq(Projections.Property<Invoice>(x => x.Prop1), model.Prop1));
// ... many more conditions :)
return m_session.QueryOver<Invoice>().Where(restrictions).List();