test code snippet


protected virtual ICriterion WhereInactiveDateIsNull
{
get
{
return Restrictions.IsNull("InactiveDate");
}
}

protected virtual IList<Entity> GetAllItems(params ICriterion[] criterion)
{
ICriteria getCriteria = Session.CreateCriteria(typeof(Entity));

if (criterion != null)
{
foreach (var criteria in criterion)
{
getCriteria.Add(criteria);
}
}

return getCriteria.List<Entity>();
}

public virtual IList<Entity> GetAll()
{
return GetAllItems();
}

public virtual IList<Entity> GetActiveItems()
{
return GetAllItems(WhereInactiveDateIsNull);
}

public virtual IList<Entity> GetItemsLikeName(string name, string columnToCompareBy)
{
ICriterion whereColumnValueStartsWithNameIgnoringCase
= Restrictions.Like(columnToCompareBy, name, MatchMode.Start).IgnoreCase();

return GetAllItems
(
WhereInactiveDateIsNull,
whereColumnValueStartsWithNameIgnoringCase
);
}
Entity Validation Ideation