明信片中奖号码,希梵仕,菠菜公社足球比分
using system; using system.collections.generic; using system.linq; using system.linq.expressions; using system.reflection; using system.text; namespace oyang.tool { public class queryablehelper { public static iqueryable<tsource> whereif<tsource>(iqueryable<tsource> source, bool istrue, expression<func<tsource, bool>> predicate) { if (istrue) { source = source.provider.createquery<tsource>( expression.call( null, where_tsource_2(typeof(tsource)), source.expression, expression.quote(predicate) )); } return source; } private static methodinfo s_where_tsource_2; private static methodinfo where_tsource_2(type tsource) => (s_where_tsource_2 ?? (s_where_tsource_2 = new func<iqueryable<object>, expression<func<object, bool>>, iqueryable<object>>(queryable.where).getmethodinfo().getgenericmethoddefinition())) .makegenericmethod(tsource); public static list<tsource> topagelist<tsource>(iqueryable<tsource> source, ref int pageindex, int pagesize, string sortfield, bool isasc, out int totalcount) { totalcount = source.count(); int pagecount = totalcount % pagesize == 0 ? totalcount / pagesize : totalcount / pagesize + 1; if (pagecount > 0 && pageindex > pagecount) { pageindex = pagecount; } var param = expression.parameter(typeof(tsource)); var body = expression.property(param, sortfield); dynamic keyselector = expression.lambda(body, param); source = isasc ? queryable.orderby(source, keyselector) : queryable.orderbydescending(source, keyselector); source = source.skip((pageindex - 1) * pagesize).take(pagesize); return source.tolist(); } public static list<tsource> topagelist<tsource>(iqueryable<tsource> source, ipagination p) { int pageindex = p.pageindex; list<tsource> temp = topagelist<tsource>(source, ref pageindex, p.pagesize, p.sortfield, p.isasc, out int totalcount); p.totalcount = totalcount; p.pageindex = pageindex; return temp; } } }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论