public int Count(Role role) { using (ISession session = NHibernateHelper.OpenSession()) { ICriteria criteria = session.CreateCriteria<Manager>(); if (role != null) { criteria.Add(Restrictions.Eq("role", role)); } return Convert.ToInt32(criteria.SetProjection(Projections.RowCount()).UniqueResult()); } }
public List<Manager> List(int page, int limit,Role role) { using (ISession session = NHibernateHelper.OpenSession()) { ICriteria criteria = session.CreateCriteria<Manager>(); criteria.AddOrder(Order.Desc("id")); if (role != null) { criteria.Add(Restrictions.Eq("role", role)); } return Tools<Manager>.IList2List(criteria.List<Manager>()); } }