/// <summary> /// 将查询语句转换为查询结果 /// </summary> /// <typeparam name="T">查询结果的类型</typeparam> /// <param name="source">查询语句</param> /// <param name="queryParam">查询参数</param> /// <returns></returns> public static ListByPages <T> ToListByPages <T>(this IQueryable <T> source, BaseSearchParam queryParam, params Object[] objects) where T : new() { if (queryParam == null) { //return null; throw new InvalidOperationException("未设置分页查询基本参数"); } if (queryParam.page < 0) { throw new InvalidOperationException("起始记录数不能小于1"); } if (queryParam.limit < 0) { throw new InvalidOperationException("每页记录数不能小于1"); } //总记录数 var totalCount = source.Count(); //总页数 var totalPageCount = 0; List <T> data = new List <T>(); if (queryParam.IsExport && queryParam.IsAllPage) { //不分页,用于导出时查询数据 data = source.OrderBy(e => queryParam.orderString).ToList(); } else { //分页数据 totalPageCount = (totalCount + queryParam.limit - 1) / queryParam.limit; data = source.OrderBy(e => queryParam.orderString).Skip(queryParam.startIndex).Take(queryParam.limit).ToList(); } //构建查询结果 var listByPages = new ListByPages <T> { rows = data, total = totalCount, totalpagecount = totalPageCount, page = queryParam.page, limit = queryParam.limit }; return(listByPages); }
/// <summary> /// 功能:列表数据绑定 /// 创建:金协民 /// 时间:2015年10月28日 /// </summary> private void Bind() { //获取数据 BaseSearchParam parm = new BaseSearchParam { index = Grid1.PageIndex + 1,//当前页数 }; Grid1.PageSize = parm.size = 20; //每页记录数(重要) //错误信息 string massage = string.Empty; var str = _rolesBll.BindData(parm, out massage); // 在查询添加之后,获取总记录数 Grid1.RecordCount = int.Parse(parm.allcount.ToString()); Grid1.DataSource = str; Grid1.DataBind(); }
/// <summary> /// 功能:列表数据绑定 /// 创建:金协民 /// 时间:2015年10月28日 /// </summary> private void BindGrid() { //获取数据 BaseSearchParam parm = new BaseSearchParam { //当前页数 index = Grid1.PageIndex + 1 }; Grid1.PageSize = parm.size; string massage = string.Empty; var modelList = T_ADMIN_BLL.BindData(parm, out massage); // 在查询添加之后,获取总记录数 Grid1.RecordCount = int.Parse(parm.allcount.ToString()); Grid1.DataSource = modelList; Grid1.DataBind(); }
/// <summary> /// 功能:列表数据绑定 /// 创建:金协民 /// 时间:2015年10月28日 /// </summary> private void BindGrid() { //获取数据 BaseSearchParam parm = new BaseSearchParam { index = Grid1.PageIndex + 1,//当前页数 orderName = "ID", }; Grid1.PageSize = parm.size = 20; //每页记录数(重要) //错误信息 string massage = string.Empty; var str = _powersbll.BindData(parm, fathercode, out massage); // 在查询添加之后,获取总记录数 Grid1.RecordCount = Int32.Parse(parm.allcount.ToString()); Grid1.DataSource = str; Grid1.DataBind(); }
/// <summary> /// 功能:列表数据绑定 /// 创建:金协民 /// 时间:2015年10月28日 /// </summary> private void BindGrid() { //获取数据 BaseSearchParam parm = new BaseSearchParam { index = Grid1.PageIndex + 1,//当前页数 desced = false, orderName = "AM_SORTINDEX", }; Grid1.PageSize = parm.size = 15; //每页记录数(重要) //错误信息 string massage = string.Empty; var str = _adminMenusBll.BindData(parm, fatherId, out massage); // 在查询添加之后,获取总记录数 Grid1.RecordCount = Int32.Parse(parm.allcount.ToString()); Grid1.DataSource = str; Grid1.DataBind(); }
/// <summary> /// 功能:列表数据绑定 /// 创建:金协民 /// 时间:2015年10月28日 /// </summary> private void BindGrid() { //获取数据 BaseSearchParam parm = new BaseSearchParam { index = Grid1.PageIndex + 1,//当前页数 desced = true, orderName = "CREATE_TIME", }; Grid1.PageSize = parm.size = 20; //每页记录数(重要) //错误信息 string massage = string.Empty; var str = _adminLoginBll.BindData(parm, out massage); // 在查询添加之后,获取总记录数 Grid1.RecordCount = int.Parse(parm.allcount.ToString()); Grid1.DataSource = str; Grid1.DataBind(); }
public PageList <T> Query(int pageIndex, int pageSize, BaseSearchParam param = null) { var util = param?.ToSearchUtil() ?? new MySearchUtil(); return(Db.Query <T>(pageIndex, pageSize, util)); }
public List <T> Fetch(BaseSearchParam param = null) { var util = param?.ToSearchUtil() ?? new MySearchUtil(); return(Db.Fetch <T>(util)); }