/// <summary> /// Executes the query. /// </summary> /// <param name="session">The <c>NHibernate</c>'s <see cref="ISession"/></param> /// <returns><c>System.Int32</c> as object</returns> protected override object InternalExecute(ISession session) { if (detachedCriteria != null) { ICriteria criteria = detachedCriteria.GetExecutableCriteria(session); criteria.SetProjection(Projections.RowCount()); Int32 count = Convert.ToInt32(criteria.UniqueResult()); // clear the projection, so our caller can re-use the DetachedCriteria criteria.SetProjection(new IProjection[] { null }); return(count); } else if (criterias != null) { ICriteria criteria = session.CreateCriteria(RootType); CriteriaHelper.AddCriterionToCriteria(criteria, criterias); criteria.SetProjection(Projections.RowCount()); return(Convert.ToInt32(criteria.UniqueResult())); } else { return(Convert.ToInt32(base.CreateQuery(session).UniqueResult())); } }
/// <summary> /// Executes the specified query and return the results /// </summary> /// <param name="session">The session to execute the query in.</param> /// <returns>the result of the query</returns> public TResult Execute(ISession session) { if (detachedCriteria != null) { return(detachedCriteria.GetExecutableCriteria(session) .SetProjection(projection) .UniqueResult <TResult>()); } else { ICriteria criteria = session.CreateCriteria(RootType); CriteriaHelper.AddCriterionToCriteria(criteria, criterions); criteria.SetProjection(projection); return(criteria.UniqueResult <TResult>()); } }
/// <summary> /// Executes the query. /// </summary> /// <param name="session">The <c>NHibernate</c>'s <see cref="ISession"/></param> /// <returns><c>ArrayList</c> as an <c>object</c></returns> protected override object InternalExecute(ISession session) { if (detachedCriteria != null) { ICriteria criteria = detachedCriteria.GetExecutableCriteria(session); return(criteria.List()); } else if (criterias != null) { ICriteria criteria = session.CreateCriteria(RootType); CriteriaHelper.AddCriterionToCriteria(criteria, criterias); return(criteria.List()); } else { return(base.CreateQuery(session).List()); } }