WebApi
                                
                                 WebApi copied to clipboard
                                
                                    WebApi copied to clipboard
                            
                            
                            
                        Allow to modify ODataQueryOptions in controller action
There are scenarios where a service needs more control over the supplied query options before they are handed over to the QueryProvider (before they are "applied" to IQueryable : queryOptions.ApplyTo(data)).
One recent scenario is the ability to drop a certain property for less privileged clients (based on the Authorization token.)
For that I imagine some code like
  var data = /* ... query data store */
  if (! privileged) 
  {
    foreach(var property in privilegedProperties) 
    {
      queryOptions.SelectExpand.SelectExpandClause.SelectedItems.Remove ( property );
    }
  }
  return queryOptions.ApplyTo(data); 
}
There are (at least) two issues --
- How to modify the SelectExpandClause in the query options. Seems like we should be able to clone/copy a new SelectExpandClause without the privileged properties, but could do something to make this easier.
- Verify that, if we modify the select expand clause used in apply, the rest of the pipeline works (i.e., the missing properties don't cause an issue with the serializer).
i would be also very interested to be able to dynamically add/remove expand property in the controller.
Sometime i would like that when i'm getting a lot of result, by default nothing is expanded but when i got one result some properties are extended. AutoExpandAttribute does not seems to allow that.