public FuncResult GetListPagination([FromBody] SearchRdModel model) { model.page--; if (model.page < 0) { model.page = 0; } return(rdBll.GetListPagination(model)); }
public FuncResult GetListPagination(SearchRdModel model) { FuncResult fr = new FuncResult() { IsSuccess = true, Message = "操作成功" }; try { var query = from r in context.ApdFctRD join o in context.ApdDimOrg on r.OrgCode equals o.OrgCode select new { CreationDate = r.CreationDate, PeriodYear = r.PeriodYear, RecordId = r.RecordId, OrgName = o.OrgName, Town = o.Town, OrgCode = o.OrgCode, RegistrationType = o.RegistrationType, Address = o.Address, IsHighTech = r.IsHighTech, RDExpenditure = r.RDExpenditure, Remark = r.Remark }; query = query.Where(f => ( (string.IsNullOrWhiteSpace(model.orgcode) || f.OrgCode.Contains(model.orgcode)) && (string.IsNullOrWhiteSpace(model.orgname) || f.OrgName.Contains(model.orgname)) && (string.IsNullOrWhiteSpace(model.year) || f.PeriodYear.Equals(Convert.ToDecimal(model.year))) )); int count = query.Count(); if (model.limit * model.page >= count) { model.page = 0; } var pagination = query.Skip(model.limit * model.page).Take(model.limit); fr.Content = new { total = count, data = pagination }; return(fr); } catch (Exception ex) { throw new Exception("error", ex); } }