title: Predicate Expression as Filter Parameter
body: <p>I'm trying to create a method that wraps a LINQ <code>Where</code> call (on an IQueryable) for filtering on a specific field in a collection and am at a loss for how to make it work.</p>
  
  <p>For example, I have a collection of Job objects similar to the following:</p>
  
  <pre><code>public class Job
  {
      public int Id { get; set; }
      public int StatusId { get; set; }
  }
  
  public class StatusItem
  {
      public int Id { get; set; }
      public string Name { get; set; }
      public bool IsAvailable { get; set; }
  
      public static readonly StatusItem Canceled = new StatusItem() { Id = (int)StatusEnum.Canceled, Name = StatusEnum.Canceled.ToString(), IsAvailable = true };
      public static readonly StatusItem Created = new StatusItem() { Id = (int)StatusEnum.Created, Name = StatusEnum.Created.ToString(), IsAvailable = true };
      public static readonly StatusItem Open = new StatusItem() { Id = (int)StatusEnum.Open, Name = StatusEnum.Open.ToString(), IsAvailable = true };
      public static readonly StatusItem Assigned = new StatusItem() { Id = (int)StatusEnum.Assigned, Name = StatusEnum.Assigned.ToString(), IsAvailable = false };
  }
  </code></pre>
  
  <p>I'm hoping to have a service method that enforces filtering using only the system defined statuses, something like this:</p>
  
  <pre><code>IEnumerable&lt;Job&gt; GetAll(Expression&lt;Func&lt;StatusItem, bool&gt;&gt; statusFilter)
  {
      // Jobs is IQueryable&lt;job&gt;. How do I apply statusFilter to Job.StatusId?
      return jobs.Where(/* some magic here? */);
  }
  </code></pre>
  
  <p>With a call similar to:</p>
  
  <pre><code>return JobService.GetAll(s =&gt; s &gt; StatusItem.Open &amp;&amp; s &lt; StatusItem.Assigned);
  </code></pre>
  
  <p><strong>Edit:</strong> Been staring too long at this. Brain now mush. Attempted to fix previous errors</p>