ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
pageSize:每页的记录数大小 pageNumber:当前页码 allCount:总记录数 ~~~ UserTab user = new UserTab(); OQL qLIST = OQL.From(user).Select().Where(cmpFun).OrderBy(user.UserName, "asc").END; qLIST.Limit(pageSize, pageNumber); qLIST.PageWithAllRecordCount = allCount; EntityQuery<UserTab >.QueryList(qLIST); ~~~ 分页泛型方法 ~~~ #region 分页 /// <summary> /// 分页查询实体列表 /// </summary> /// <param name="pageSize">每页数据</param> /// <param name="curPage">当前页</param> /// <param name="recordCount">总记录数</param> /// <param name="cmpFunc">条件</param> /// <param name="orderBy">排序</param> /// <param name="act">查询后的实体填充方法</param> /// <returns></returns> public static List<T> GetList(int pageSize, int curPage, ref int recordCount, OQLCompareFunc<T> cmpFunc, OQLOrderAction<T> orderBy, Action<T> act = null) { T entity = new T(); OQL q = OQL.From(entity).Select().Where<T>(cmpFunc).OrderBy(orderBy).END; q.Limit(pageSize, curPage); q.PageWithAllRecordCount = recordCount; var lst = EntityQuery<T>.QueryList(q); //第一次查询时得到真实页数 if (recordCount == 0) { recordCount = q.PageWithAllRecordCount; } if (lst.Count > 0 && null != act) { lst.ForEach(d => act(d)); } return lst; } #endregion 分页 ~~~