public async Task <IActionResult> Get() { var entityQuery = _aircraftService.GetAircrafts(); var filter = HttpContext.Request.Query["filter"].ToString(); if (!string.IsNullOrEmpty(filter) && filter != "{}") { var filterVals = (JObject)JsonConvert.DeserializeObject(HttpContext.Request.Query["filter"]); foreach (var f in filterVals) { entityQuery = entityQuery.Where($"{f.Key}.Contains(@0)", f.Value.ToString()); } } var count = entityQuery.Count(); if (!string.IsNullOrEmpty((HttpContext.Request.Query["sort"]))) { var sortVal = JsonConvert.DeserializeObject <List <string> >((HttpContext.Request.Query["sort"])); var condition = sortVal.First(); var order = sortVal.Last() == "ASC" ? "" : "descending"; entityQuery = entityQuery.OrderBy($"{condition} {order}"); } var range = JsonConvert.DeserializeObject <List <string> >((HttpContext.Request.Query["range"])); var from = Convert.ToInt32(range.First()); var to = Convert.ToInt32(range.Last()); entityQuery = entityQuery.Skip(from).Take(to - from + 1); Response.Headers.Add("Access-Control-Expose-Headers", "Content-Range"); Response.Headers.Add("Content-Range", $"{typeof(Aircraft).Name.ToLower()} {from}-{to}/{count}"); //return new JsonResult(entityQuery.ToListAsync()); return(Ok(await entityQuery.ToListAsync())); }