其他分享
首页 > 其他分享> > API

API

作者:互联网

一、HTTP 协议(超文本传输协议)

二、创建Web API

三、WebApi 和 MVC 控制器的区别

四、webapi 返回类型

五、API分页

例子:
public class StudentDal
  {
      StudentDbContext db = new StudentDbContext();
      public List<Student> show(ref int totalcount,ref int totalpage,int pageindex,int pagesize)
      {
          IQueryable<Student> quer = db.Students.Include("NClass");
          totalcount = quer.Count();
          totalpage = Convert.ToInt32(Math.Ceiling(totalcount * 1.0 / pagesize));
          return quer.OrderBy(p => p.Sid).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
      }
  }
 例子:
StudnetBll bll = new StudnetBll();
      [HttpGet]//声明get请求
      public IHttpActionResult Show(int pageindex = 2,int pagesize=3)
      {
          int totalcount = 0;
          int totalpage = 0;
          var list = bll.show(ref totalcount, ref totalpage, pageindex, pagesize);
          var pagelist = new StaticPagedList<Student>(list, pageindex, pagesize, totalcount);
          return Json(pagelist);//返回json
      }

 

标签:Web,pageindex,请求,pagesize,int,totalcount,API
来源: https://www.cnblogs.com/dvzvhj/p/15032356.html