.Net Core 2.1中的传呼机

时间:2019-01-16 16:54:52

标签: c# asp.net-mvc asp.net-core paging asp.net-core-2.1

我从NuGet Link添加了ReflectionIT.Mvc.Paging,但是我遇到了问题。

在控制器中,我有2种方法,索引和组织。当我在“组织”视图上并按控制器中数字为“ 2”的页面转到索引而不是“组织”方法时。

如何强制它继续执行我想要的方法或扩展此select dt1.company_id, max(dt1.unique_entry_id) keep (dense_rank first order by case dt1.rating_number when 2 then 1 when 1 then 2 when 3 then 3 end) as unique_entry_id from comp_results dt1 group by dt1.company_id; 以将方法名称作为参数传递?

控制器:

@await this.Component.InvokeAsync("Pager", new { pagingList = this.Model })

查看:

   public IActionResult Index()
        {

            return View();
        }

     public async Task<IActionResult> Organizations(int page=1)
        {
            var userlist = _context.Users.Include(u => u.UserRoles).ThenInclude(u => u.Role).Where(o => o.UserRoles.All(r => r.Role.Name == "Company") && o.IsActive == true).AsNoTracking().OrderByDescending(o => o.Company);
            var model = await PagingList.CreateAsync(userlist, 2, page);
            return View(model);



        }

1 个答案:

答案 0 :(得分:1)

您可以将Action属性设置为PagingList对象:

var model = await PagingList.CreateAsync(userlist, 2, page);
model.Action = "Organizations";