EF分页查询
/// <summary> /// 查询所有商品 /// </summary> /// <param name="pageNum">第几页</param> /// <param name="pageSize">每页多少条数据</param> /// <returns></returns> // GET: api/<ShangpinController> [HttpGet] public async Task<ActionResult<IEnumerable<SHANGPIN>>> Get(int pageNum, int pageSize) { var goods = await _dataContext.Shangpin .AsNoTracking() .OrderBy(g => g.SPDM) .Skip((pageNum-1)*pageSize+1) .Take(pageNum*pageSize) .ToListAsync(); if (goods != null) { return new ObjectResult(new { code = 200, msg = "查询成功", count = goods.Count, result = goods }); } return new ObjectResult(new { code = 404, sub_msg = "未查询到数据", msg = "" }); }
本文来自博客园,作者:liessay,转载请注明原文链接:https://www.cnblogs.com/liessay/p/14240954.html