I have written the code below. I want to display the page list and foreign keys of table.
Please help me solve this confusing problem since I only have 1 view().
public ActionResult Index(int? page)
{
var books = db.Books.Include(b => b.Authors)
.Include(b => b.BookTypes)
.Include(b => b.Categories)
.Include(b => b.Publishers).ToList();
var model = db.Books.OrderByDescending(m => m.Id).ToPagedList(page ?? 1, 10);
return View(books);
}
Try this code
var list = db.Books.OrderByDescending(m => m.Id).ToList();
int pageSize = 10;
int pageNumber = (page ?? 1);
return View(list.ToPagedList(pageNumber, pageSize));
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.