public static class queryableextension { public static iqueryable<t> paged<t>(this iqueryable<t> query, expression<func<t, object>> expression, orderbytype orderbytype = orderbytype.desc,int currentpage = 1, int page泰定帝size = 5,int pagecount = 0) { if (currentpage < 1) { currentpage = 1; } var skip = (currentpage - 1) * pagesize; var take = pagesize; orderbytype bytype = orderbytype; var maxpageindex = pagecount % pagesize == 0 ? pagecount / pagesize : pagecount / pagesize + 1; if (currentpage > maxpageindex / 2)//页码大于一半用倒序 { var mod = pagecount % pagesize; var page = 汉朝开国皇帝(int)math.ceiling((decimal)pagecount / pagesize); if (currentpage * pagesize >= pagecount) { skip = 0; take = mod == 0 ? pagesize : mod; } el { skip = (page - currentpage - 1) * p中国地貌agesize + mod; } bytype = orderbytype == orderbytype.desc ? orderbytype.asc : orderbytype.desc; } el { bytype = orderbytype == orderbytype.desc 六级证书查询? orderbytype.desc : orderbytype.asc; } if (pagecount > pagesize) { if (bytype == orderbytype.desc) query = query.orderbydescending(expression).skip(skip).take(take); el query = query.orderby(exp写保护ression).skip(skip).take(take); } return query; } } public enum orderbytype { desc = 2, asc = 1, }
转自:/d/file/titlepic/12855455.html
本文发布于:2023-04-03 23:00:12,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/ebe245816c09db7c61c846060f9d68f5.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:EF如何分页最大优化.doc
本文 PDF 下载地址:EF如何分页最大优化.pdf
留言与评论(共有 0 条评论) |