public async Task <IActionResult> Index([FromServices] TengoDbContext db, PageInfo pageInfo, int articleTypeId = 0, string keyword = null, string sortBy = null) { var query = db.Article.AsQueryable(); if (articleTypeId > 0) { query = query.Where(p => p.ArticleTypeId == articleTypeId); } if (!string.IsNullOrWhiteSpace(keyword)) { keyword = keyword.Trim(); query = query.Where(p => p.Title.Contains(keyword)); } ViewData.Model = await db.GetPageListAsync(query, pageInfo.Page, pageInfo.PageSize); ViewBag.Keyword = keyword; ViewBag.ArticleTypeId = articleTypeId; ViewBag.ArticleTypeIds = new SelectList(await service.ArticleTypeList(), "Id", "TypeName", articleTypeId); return(View()); }