namespace FirstProject.Controllers { [ApiController] [Route("/[controller]")] public class WeatherForecastController : ControllerBase { private readonly ILogger<WeatherForecastController> _logger; public WeatherForecastController(ILogger<WeatherForecastController> logger) { _logger = logger; } [HttpGet] public String Get(bool IsEnable, int limit = 1, int page = 0) { object obj = null; string value = Request.QueryString.Value;//获取get参数 value = value.Replace("?", ""); User user= Newtonsoft.Json.JsonConvert.DeserializeObject<User>(value); using (var db = new BloggingContext()) { // Read obj = db.User .Where(u => u.IsEnable== IsEnable && u.IsDelete == false)//查询条件 .OrderByDescending(u => u.Id)//排序 .Select(c => new//查询指定字段 { u.Id, u.Username }).Skip(page).Take(limit)//分页 .ToList(); } return Newtonsoft.Json.JsonConvert.SerializeObject(obj); } } }