title: Web API 2 REST Service Advanced Data Filtering
body: <p>My team has currently implemented a REST API (JSON) using the Web API 2 platform for .NET. We have some working URLs, such as:</p>
  
  <pre><code>/api/schools 
  /api/schools/5000 
  /api/occupations 
  /api/occupations/22
  </code></pre>
  
  <p>And here is some of our data controller code:</p>
  
  <pre><code>public class OccupationsController : ApiController
  {
      // /api/Occupations/1991
      public IHttpActionResult GetOccupation(int id)
      {
          var occupation = GetAllOccupations().FirstOrDefault((p) =&gt; p.OccupationID == id);
          if (occupation == null)
          {
              return NotFound();
          }
          return Ok(occupation);
      }
      // /api/occupations
      public IEnumerable&lt;Occupation&gt; GetAllOccupations()
      {
          var ctx = new TCOSDBEntities();
          return ctx.Occupations.OrderBy(occupation =&gt; occupation.Title);          
      }
  
  }
  </code></pre>
  
  <p>We are now introducing data filtering (based on user checkbox selection) and I am curious how to approach this in our existing API, or if I should abandon REST for filtering down and try a different approach all together?</p>
  
  <p>Here is our checkbox filtering mechanism:
  <a href="http://i.stack.imgur.com/OjVeN.png" rel="nofollow">Checkbox UI</a></p>
  
  <p>How can I introduce search parameters in my REST services and DataController methods? Like, how do I get a range filter on a field (like Cost?)? Can I have multiple fields filtering, like Cost, Tuition, etc?</p>