/// <summary> /// 转换为分页列表 /// </summary> /// <typeparam name="T">实体类型</typeparam> /// <param name="source">数据源</param> /// <param name="pager">分页对象</param> public static PagerList <T> ToPageList <T>(this IEnumerable <T> source, IPager pager) { var result = new PagerList <T>(pager); result.AddRange(source.ToList()); return(result); }
/// <summary> /// 创建分页列表 /// </summary> private static PagerList <T> CreatePageList <T>(IEnumerable <T> source, IPager pager) { var result = new PagerList <T>(pager); result.AddRange(source.ToList()); return(result); }
public PagerList<User> Query(UserQuery query) { if (string.IsNullOrWhiteSpace(query.Order)) //分页必须先进行排序 query.Order = "Id desc"; query.TotalCount = UserRepository.GetAllFilterDataPermissions().Count(); IQueryable<User> users = GetQueryConditions(UserRepository.GetAllFilterDataPermissions(), query) //where查询条件必须放在排序和分页前,不然生成SQL有BUG .OrderByIfOrderNullOrEmpty(query.Order) .Skip(query.GetSkipCount()) .Take(query.PageSize); var result = new PagerList<User>(query); result.AddRange(users.ToList()); return result; }
public PagerList<Resource> Query(ResourceQuery query) { if (string.IsNullOrWhiteSpace(query.Order)) //分页必须先进行排序 query.Order = "Id desc"; query.TotalCount = ResourceRepository.GetAll().Count(); IQueryable<Resource> roles = GetQueryConditions(ResourceRepository.GetAll(), query) //where查询条件必须放在排序和分页前,不然生成SQL有BUG .OrderByIfOrderNullOrEmpty(query.Order) .Skip(query.GetSkipCount()) .Take(query.PageSize); var result = new PagerList<Resource>(query); result.AddRange(roles.ToList()); return result; }
public virtual PagerList <TDto> FetchPages(TQuery query) { string fetchQuery = GetQuerySqlId(); int total = 0; int wiilShowedPage = query.Page; int pageSize = query.PageSize; IList <TDto> list = DataMapper.QueryForListWithPage <TDto>(fetchQuery, query, query.Order, wiilShowedPage, pageSize, ref total); query.TotalCount = total; PagerList <TDto> pagers = new PagerList <TDto>(query); pagers.AddRange(list); return(pagers); }
/// <summary> /// 转换为分页列表 /// </summary> /// <typeparam name="TEntity">实体类型</typeparam> /// <param name="source">数据源</param> /// <param name="pager">分页对象</param> /// <returns></returns> public static PagerList <TEntity> ToPagerList <TEntity>(this IQueryable <TEntity> source, IPager pager) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (pager == null) { throw new ArgumentNullException(nameof(pager)); } var result = new PagerList <TEntity>(pager); result.AddRange(source.ToList()); return(result); }
public PagerList <User> Query(UserQuery query) { if (string.IsNullOrWhiteSpace(query.Order)) //分页必须先进行排序 { query.Order = "Id desc"; } query.TotalCount = UserRepository.GetAllFilterDataPermissions().Count(); IQueryable <User> users = GetQueryConditions(UserRepository.GetAllFilterDataPermissions(), query) //where查询条件必须放在排序和分页前,不然生成SQL有BUG .OrderByIfOrderNullOrEmpty(query.Order) .Skip(query.GetSkipCount()) .Take(query.PageSize); var result = new PagerList <User>(query); result.AddRange(users.ToList()); return(result); }
public PagerList <Role> Query(RoleQuery query) { if (string.IsNullOrWhiteSpace(query.Order)) //分页必须先进行排序 { query.Order = "Id desc"; } query.TotalCount = RoleRepository.GetAll().Count(); IQueryable <Role> roles = GetQueryConditions(RoleRepository.GetAll(), query) //where查询条件必须放在排序和分页前,不然生成SQL有BUG .OrderByIfOrderNullOrEmpty(query.Order) .Skip(query.GetSkipCount()) .Take(query.PageSize); var result = new PagerList <Role>(query); result.AddRange(roles.ToList()); return(result); }
//[DisableFiltersAttribute(FiltersEnum.SoftDelete)] //示范:关闭数据过滤器(参数为过滤器名称列表) public PagerList <UserDto> Query(UserQuery query) { //todo:easyui组件的ajax请求异常,暂时无法拦截 //throw new Exception("用户查询异常,easyui ajax操作全局异常测试"); if (string.IsNullOrWhiteSpace(query.Order)) //分页必须先进行排序 { query.Order = "Id desc"; } query.TotalCount = _userRepository.GetAllFilterDataPermissions().Count(); IQueryable <User> users = GetQueryConditions(_userRepository.GetAllFilterDataPermissions(), query) //where查询条件必须放在排序和分页前,不然生成SQL有BUG .OrderByIfOrderNullOrEmpty(query.Order) .Skip(query.GetSkipCount()) .Take(query.PageSize); var result = new PagerList <User>(query); result.AddRange(users.ToList()); return(result.Convert(p => p.ToDto())); }
public virtual PagerList <TDto> FetchPages(TQuery query) { PagerList <TDto> pagers = new PagerList <TDto>(0); try { string fetchQuery = GetQuerySqlId(); int total = 0; int wiilShowedPage = query.Page; int pageSize = query.PageSize; IList <TDto> list = DataMapper.QueryForListWithPage <TDto>(fetchQuery, query, query.Order, wiilShowedPage, pageSize, ref total); query.TotalCount = total; pagers = new PagerList <TDto>(query); pagers.AddRange(list); } catch (Exception e) { LogOuts.Info("FetchPages error:" + e.ToString()); } return(pagers); }
public PagerList<UserDto> Query(UserQuery query) { //todo:easyui组件的ajax请求异常,暂时无法拦截 //throw new Exception("用户查询异常,easyui ajax操作全局异常测试"); if (string.IsNullOrWhiteSpace(query.Order)) //分页必须先进行排序 query.Order = "Id desc"; query.TotalCount = _userRepository.GetAllFilterDataPermissions().Count(); IQueryable<User> users = GetQueryConditions(_userRepository.GetAllFilterDataPermissions(), query) //where查询条件必须放在排序和分页前,不然生成SQL有BUG .OrderByIfOrderNullOrEmpty(query.Order) .Skip(query.GetSkipCount()) .Take(query.PageSize); var result = new PagerList<User>(query); result.AddRange(users.ToList()); return result.Convert(p => p.ToDto()); }