简体   繁体   中英

Asp.net MVC PagedList Order

My problem is exactly the same as this one: toPagedList() order differs from the LINQ order by clause

That question was posted two years ago and there's no solution yet. I'm hoping someone have answers now. Sorry if this kind of question is not allowed.

EDIT: Here is my LINQ statement

(db.Transactions.OrderByDescending(t => t.ReservationDate)).ToList();

Hi I dont have idea about ToPagedList() method but you can try that problem this way

int? page=1;
            int pageSize = 3; 
            int pageNumber = (page ?? 1);
            int numberOfItemsTobeSkipped = (pageNumber-1)  * pageSize;
            var links =( from l in LINKS
                        orderby l.ID descending
                         select l).Skip(numberOfItemsTobeSkipped).Take(pageSize).ToList();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM