public ActionResult <IEnumerable <Internship> > GetInternships([FromQuery] string search, int pageNumber = 1, int PageSize = 10) { List <Internship> interns; if (!String.IsNullOrEmpty(search)) { string sql = "SELECT * FROM " + _table + " WHERE (InternshipBody like('%" + search + "%') or InternshipType like ('%" + search + "%') or InternshipTitle like('%" + search + "%'))"; interns = _context.Internships.FromSqlRaw(sql).Include(u => u.User).OrderBy(x => x.InternshipExpDate).ToList(); } else { interns = _context.Internships.Include(u => u.User).OrderBy(x => x.InternshipCreatedAt).ToList(); } // Make sensitive info like salt and password null or empty var filtered = UserFilter.RemoveUserInfoFromInternship(interns); // the Response class will shows if the data is paginated or require token (Auth). var response = new Response <List <Internship> >(PaginationQuery <Internship> .CreateAsync(filtered, pageNumber, PageSize), false, true); return(Ok(response)); }