コード例 #1
0
        //getPagedEntities not use
        public IEnumerable <T> GetPagedEntities(int pageSize, int pageIndex, out int total, Expression <Func <T, bool> > predicate, Expression <Func <T, object> > keySelector, bool isAsc)
        {
            int skipCount = pageSize * (pageIndex - 1);

            total = 0;
            //create  sqlQuery
            SQLinq <T> query = new SQLinq <T>().Where(predicate);

            if (isAsc)
            {
                query = query.OrderBy(keySelector);
            }
            else
            {
                query = query.OrderByDescending(keySelector);
            }
            query.Skip(skipCount).Take(pageSize);
            //do  query
            return(Query(query));
        }
コード例 #2
0
 public static SQLinq <T> Page <T>(this SQLinq <T> query, int page, int pageSize)
 {
     return(query
            .Skip(pageSize * (page - 1))
            .Take(pageSize));
 }