public void GetSchools() { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; string searchKey = HttpContext.Request.Params["search"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); int total = 0; SchoolInfoManager manager = new SchoolInfoManager(); List <SchoolInfoEntity> list = manager.GetSearch(searchKey, sort, order, offset, pageSize, out total); //给分页实体赋值 PageModels <SchoolInfoEntity> model = new PageModels <SchoolInfoEntity>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = list; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); }
public string GetAll(string order, string sort, string searchKey, int offset, int pageSize) { int total = 0; SchoolInfoManager manager = new SchoolInfoManager(); List <SchoolInfoEntity> list = manager.GetSearch(searchKey, sort, order, offset, pageSize, out total); //给分页实体赋值 PageModels <SchoolInfoEntity> model = new PageModels <SchoolInfoEntity>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = list; //将查询结果返回 return(new JavaScriptSerializer().Serialize(model)); }