提示:分页查询时,尽量显式地指定排序规则
[HttpGet("{pageIndex:int}/{pageSize:int}")] public async Task<ActionResult<IEnumerable<Book>>> GetPage(int pageIndex, int pageSize) { IQueryable<Book> query = _context.Books.Where(m => m.Title.Contains("之")); long count = query.LongCount();//总记录数 long pageCount = (long)Math.Ceiling(count * 1.0 / pageSize);//页数 query = query.Skip((pageIndex - 1) * pageSize).Take(pageSize); var list = await query.ToListAsync(); return Ok(list); }
标签:Core,pageIndex,分页,pageSize,int,EF,long,query From: https://www.cnblogs.com/friend/p/16746964.html