我正在尝试使用 Skip Take in Code Frist 方法进行分页但给出错误
I am try to Pagination using Skip Take in Code Frist Approach But given Error
我正在尝试使用代码优先方法中的 Skip Take 进行分页,但出现错误。
方法
[HttpPost]
[Route("Paging")]
public async ActionResult<IEnumerable<City>> Paging(int CurrentPage)
{
CurrentPage = CurrentPage;
return _dropdowncontext.cities.OrderBy(x=>x.CityId).Skip((CurrentPage - 1) * 5).Take(5);
}
[HttpPost]
[Route("Paging")]
public async Task <ActionResult<IQueryable<City>>> Paging(int CurrentPage=1)
{
var abc= await _dropdowncontext.cities.OrderBy(x=>x.CityId).Skip((CurrentPage - 1) * 5).Take(5).ToListAsync();
if (!abc.Any())
return NotFound();
return Ok(abc);
}
我正在尝试使用代码优先方法中的 Skip Take 进行分页,但出现错误。
方法
[HttpPost]
[Route("Paging")]
public async ActionResult<IEnumerable<City>> Paging(int CurrentPage)
{
CurrentPage = CurrentPage;
return _dropdowncontext.cities.OrderBy(x=>x.CityId).Skip((CurrentPage - 1) * 5).Take(5);
}
[HttpPost]
[Route("Paging")]
public async Task <ActionResult<IQueryable<City>>> Paging(int CurrentPage=1)
{
var abc= await _dropdowncontext.cities.OrderBy(x=>x.CityId).Skip((CurrentPage - 1) * 5).Take(5).ToListAsync();
if (!abc.Any())
return NotFound();
return Ok(abc);
}