zoukankan      html  css  js  c++  java
  • Intern Day26

            [Route("api/patients")]
            [HttpGet]
           // [HttpGet("pat0")]
            public List<Patient> list(string keyword, int pageIndex, int pageSize)
            {
                var skip=pageSize*(pageIndex-1);
                var patient = _patientDbContext.Patients
                    .Where(it=>it.Name.Contains(keyword)) // Where属于Linq下的
                    // 从两端模糊匹配
                    // 相当于pgsql中的
                    // select * from platform.patient where name like '%keyword%'
                    // offset 40 limit 20; 
                   
                    // Skip和Take一般放一起用,一般用于分页
                    .Skip(skip) // 跳过前skip个元素
                    .Take(pageSize) // 获取前pageSize个元素
                    
                    .ToList();
                return patient;
            }
    

    带排序的写法,PageSize参数由前端传给后端:

    var pageFiles = validFiles.OrderByDescending(x => x.CreateTime).Skip((input.PageIndex - 1) * input.PageSize).Take(input.PageSize).ToList();
    
  • 相关阅读:
    二人组
    对于软件工程的理解
    shell 远程链接
    shell变量
    shell教程
    正则表达式--练习
    git--版本库
    git-版本回退
    git--时光穿梭
    git安装
  • 原文地址:https://www.cnblogs.com/OFSHK/p/14537470.html
Copyright © 2011-2022 走看看