/// <summary> /// Returns only a selected field of all itens on criteria /// </summary> /// <typeparam name="TProjectionType">The type of the projection type.</typeparam> /// <param name="type">The type.</param> /// <param name="criteria">The criteria.</param> /// <param name="field">The field.</param> /// <returns></returns> public static List <TProjectionType> ProjectionFindAll <TProjectionType>(Type type, Criteria criteria, string field) { CheckTypeAtrribute(type); try { criteria.SQLString = ActiveRecordMaster.MakeProjectionFullSelect(type, field); //Commit Filters criteria.CommitFilters(); return(ActiveRecordMaster.ExecuteProjectionQueryCriteria <TProjectionType>(criteria)); } catch (Exception ex) { LogManager.Log("Monty.ActiveRecord", LogCategory.Error, String.Format("Error when tries to execute ActiveRecordBase.FindAll(type: [{0}])", type), ex); return(null); } }
/// <summary> /// Returns only a selected field of a portion itens on criteria /// </summary> /// <typeparam name="TProjectionType">The type of the projection type.</typeparam> /// <param name="type">The type.</param> /// <param name="criteria">The criteria.</param> /// <param name="field">The field.</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> /// <returns></returns> /// <exception cref="AttributeNotFoundException"></exception> public static List <TProjectionType> SlicedProjectionFindAll <TProjectionType>(Type type, Criteria criteria, string field, 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 { numberOfPages = -1; numberOfItems = -1; } //Query criteria.IncludeOrderBy = true; criteria.SQLString = ActiveRecordMaster.MakeProjectionFullSelect(type, field); criteria.CommitFilters(); criteria.MakePaginator(currentPage, pageSize); return(ActiveRecordMaster.ExecuteProjectionQueryCriteria <TProjectionType>(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); } }