/// <summary> /// Finds all. /// </summary> /// <param name="type">The type.</param> /// <param name="criteria">The criteria.</param> /// <returns></returns> public static List <ActiveRecordBase> FindAll(Type type, Criteria criteria) { CheckTypeAtrribute(type); try { criteria.SQLString = ActiveRecordMaster.MakeFullSelect(type); //Commit Filters criteria.CommitFilters(); return(ActiveRecordMaster.ExecuteQueryCriteria(type, criteria)); } catch (Exception ex) { LogManager.Log("Monty.ActiveRecord", LogCategory.Error, String.Format("Error when tries to execute ActiveRecordBase.FindAll(type: [{0}])", type), ex); throw ex; } }
/// <summary> /// Return a portion of the itens on the criteria. /// </summary> /// <param name="type">The type.</param> /// <param name="criteria">The criteria.</param> /// <param name="currentPage">The current page.</param> /// <param name="pageSize">Size of the page.</param> /// <param name="numberOfPages">The number of pages.</param> /// <param name="numberOfItems">The number of items.</param> /// <param name="findNumberOfPages">if set to <c>true</c> [find number of pages].</param> /// <returns></returns> /// <exception cref="AttributeNotFoundException"></exception> public static List <ActiveRecordBase> SlicedFindAll(Type type, Criteria criteria, int currentPage, int pageSize, out int numberOfPages, out int numberOfItems, bool findNumberOfPages) { CheckTypeAtrribute(type); try { if (findNumberOfPages) { //Count float count = ActiveRecordBase.Count(type, criteria); numberOfItems = (int)count; count = ((float)count / pageSize); numberOfPages = (count) != ((int)count) ? ((int)count) + 1 : ((int)count); } else { numberOfItems = -1; numberOfPages = -1; } //Query criteria.IncludeOrderBy = true; criteria.SQLString = ActiveRecordMaster.MakeFullSelect(type); criteria.CommitFilters(); //.CommitSlicedFilters((currentPage - 1) * pageSize, pageSize); //MakePaginator criteria.MakePaginator(currentPage, pageSize); return(ActiveRecordMaster.ExecuteQueryCriteria(type, criteria)); } catch (Exception ex) { LogManager.Log("Monty.ActiveRecord", LogCategory.Error, String.Format("Error when tries to execute ActiveRecordBase.SlicedFindAll(type: [{0}])", type), ex); numberOfItems = 0; numberOfPages = 0; return(null); } }