C# Linq分页
//搜索结果listDicResult List<Dictionary<string, string>> listDicResult = new List<Dictionary<string, string>>(); if (RegExp.IsNull(bankName)) { listDicResult = listDicCache; } else { foreach (var itemDic in listDicCache) { if (itemDic.Values.FirstOrDefault().Contains(bankName)) { listDicResult.Add(itemDic); } } } //总行数 int totalCount = listDicResult.Count(); //总页数(pageCount)=总行数(totalCount)/每页大小(PageSize) decimal PageCountDecimal = Math.Ceiling((decimal)totalCount / pageSize); int pageCount = Convert.ToInt32(PageCountDecimal); //Linq分页 listDicResult = (from u in listDicResult //orderby u.UserID //排序字段,没有就不写 //Skip跳过多少行,Take取多少行,pageNumber看需求调整(有可能是0有可能是1) select u).Skip(pageSize * (pageNumber)).Take(pageSize).ToList(); //返回结果 return listDicResult;
搜索
复制
标签:分页,pageSize,C#,itemDic,Linq,totalCount,listDicResult From: https://www.cnblogs.com/jankie1122/p/11108739.html