title: OData v4 post-processing of results (works with v3, not with v4)
body: <p>I have a Web API server (with EF 6.x) and I need to do some post-processing of the result set from OData queries in the controller.  On the client-side I use a DevEx grid and their ODataInstantFeedbackSource.</p>
  
  <p>With no post-processing, everything works fine, e.g.:</p>
  
  <p><a href="http://somesite.us/odata/Items/" rel="nofollow noreferrer">http://somesite.us/odata/Items/</a>$count</p>
  
  <pre><code>[EnableQuery]
  public IHttpActionResult GetItems(ODataQueryOptions&lt;Item&gt; queryOptions)
  {
      return Ok(Context.Items);
  }
  </code></pre>
  
  <p>It does <em>not</em> work with post-processing (same simple $count query, but without EnableQuery since I am manually applying the query options):</p>
  
  <p>GET <a href="http://somesite.us/odata/Items/" rel="nofollow noreferrer">http://somesite.us/odata/Items/</a>$count</p>
  
  <pre><code>//[EnableQuery]
  public IHttpActionResult GetItems(ODataQueryOptions&lt;Item&gt; queryOptions)
  {
      queryOptions.Validate(_validationSettings);
      var query = queryOptions.ApplyTo(Context.Items, new ODataQuerySettings()) as IQueryable&lt;Item&gt;;
      var resultList = new List&lt;Item&gt;();
      foreach (var item in query)
      {
          item.OrdStat = "asf"; // Some post-processing
          resultList.Add(item);
      }
      return Ok(resultList.AsQueryable());
  }
  </code></pre>
  
  <p>This throws an exception:</p>
  
  <pre><code>Microsoft.OData.ODataException
    HResult=0x80131509
    Message=The value of type 'System.Linq.EnumerableQuery`1[[SomeService.Model.Item, SomeService.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' could not be converted to a raw string.
    Source=Microsoft.OData.Core
    StackTrace:
     at Microsoft.OData.RawValueWriter.WriteRawValue(Object value)
  </code></pre>
  
  <p><em>Note: with ODATA v3, the above works just fine.  It is only with v4 that I get an exception when not using [EnableQuery].</em></p>
  
  <p>If I add back the [EnableQuery] attribute, this simple $count query works with ODATA v4, but with more complex queries, the data returned to the client gets messed up (likely due to $skip, etc. being applied both by me and by the EnableQuery attribute).</p>
  
  <p>For example, this query generated by the DevEx grid when you scroll down:
  <a href="http://somesite.us/odata/Items" rel="nofollow noreferrer">http://somesite.us/odata/Items</a>?$orderby=ItemNo&amp;$skip=300&amp;$top=201</p>
  
  <p>Results in (client-side): <em>Unexpected number of returned keys: 0. Expected: 201</em></p>
  
  <p>I assume that I need to remove the EnableQuery attribute since I am manually applying the query options, but why am I getting the "could not be converted to a raw string" exception when I do this?  </p>
  
  <p><strong>How can I properly implement post-processing in this scenario?</strong></p>