/// <summary> /// 分页查询并转换到仓储DTO对象 /// </summary> /// <typeparam name="TEntity">数据实体对象</typeparam> /// <typeparam name="DtoTEntity">仓储实体对象</typeparam> /// <param name="queryable">主查询表达式(必须包含排序)</param> /// <param name="pageModel">分页属性对象</param> /// <returns></returns> public static PagedResultDto <DtoTEntity> GetPagingData <TEntity, DtoTEntity>(this IOrderedQueryable <TEntity> queryable, PagingDto pageModel) { queryable = queryable.ApplyThenSorting(pageModel); var pagedResultDto = queryable.BuildPaging(pageModel); //完成映射 var data = pagedResultDto.Items.MapTo <List <DtoTEntity> >(); return(new PagedResultDto <DtoTEntity>(pagedResultDto.TotalCount, data)); }
/// <summary> /// 分页查询到实体对象 /// </summary> /// <typeparam name="TEntity"></typeparam> /// <param name="queryable"></param> /// <param name="pageModel"></param> /// <returns></returns> public static PagedResultDto <TEntity> GetPagingData <TEntity>(this IOrderedQueryable <TEntity> queryable, PagingDto pageModel) { queryable = queryable.ApplyThenSorting(pageModel); return(queryable.BuildPaging(pageModel)); }