/// <summary> /// 根据查询条件、每页数量,返回分页数据集合 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="condition">查询条件</param> /// <param name="pageSize">每页需要显示的数据量</param> /// <returns>分页数据列表,包括当前页、总记录数、分页条等</returns> public static DataPage <T> findPage <T>(String condition, int pageSize) where T : IEntity { if (pageSize <= 0) { pageSize = 20; } ObjectInfo state = new ObjectInfo(typeof(T)); state.includeAll(); state.Pager.setSize(pageSize); IPageList result = ObjectPool.FindPage(typeof(T), condition, state.Pager); if (result == null) { IList list = ObjectDb.FindPage(state, condition); ObjectPage p = state.Pager; ObjectPool.AddPage(typeof(T), condition, p, list); result = new PageList(); result.Results = list; result.PageCount = p.PageCount; result.RecordCount = p.RecordCount; result.Size = p.getSize(); result.PageBar = p.PageBar; result.Current = p.getCurrent(); } else { result.PageBar = new ObjectPage(result.RecordCount, result.Size, result.Current).PageBar; } return(new DataPage <T>(result)); }
/// <summary> /// 根据查询条件、当前页码和每页数量,返回分页数据集合 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="condition">查询条件</param> /// <param name="current">当前页码(从0开始)</param> /// <param name="pageSize">每页需要显示的数据量</param> /// <returns>分页数据列表,包括当前页、总记录数、分页条等</returns> public static DataPage <T> findPage <T>(String condition, int current, int pageSize) where T : IEntity { ObjectInfo state = new ObjectInfo(typeof(T)); state.includeAll(); state.Pager.setSize(pageSize); current++; state.Pager.setCurrent(current); IList list = ObjectDb.FindPage(state, condition); IPageList result = new PageList(); result.Results = list; result.PageCount = state.Pager.PageCount; result.RecordCount = state.Pager.RecordCount; result.Size = state.Pager.getSize(); result.PageBar = state.Pager.PageBar; result.Current = state.Pager.getCurrent(); return(new DataPage <T>(result)); }