// GET: Suppliers public async Task <IActionResult> Index(string currentSort, int?page) { int pageIndex = 1; int pageSize = 5; //判断page是否有值,有的话就给值,没有就赋值1 pageIndex = page.HasValue ? Convert.ToInt32(page) : 1; IPagedList <Supplier> lstStudent = null; lstStudent = await _context.Set <Supplier>().Include("SupplierType").OrderByDescending(s => s.SupplierName).ToPagedListAsync(pageIndex, pageSize); return(View(lstStudent)); }
public IViewComponentResult Invoke(string currentSort, int?page) { int pageIndex = 1; int pageSize = 5; //判断page是否有值,有的话就给值,没有就赋值1 pageIndex = page.HasValue ? Convert.ToInt32(page) : 1; IPagedList <Supplier> lstStudent = null; lstStudent = _context.Set <Supplier>().Include("SupplierType").OrderByDescending(s => s.SupplierName).ToPagedList(pageIndex, pageSize); return(View(lstStudent)); }
public Repository(SupplierContext context) { Context = context; DbSet = context.Set <T>(); }
public GenericRepository(SupplierContext dbContext) { _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); _dbSet = _dbContext.Set <T>(); }