1

Closed

OdataQueryOptions does not override NotSupported on QueryableAttribute

description

If you have a class decorated with Queryable and then override the OData Queryable on a specific method in that class with ODataQueryOptions the Queryable Attribute will still throw a not supported error even if you have implemented that specific $filter.

This is a pretty common case where you'd want the default Queryable and then customize one or two methods in the class. Taking the Queryable attribute off the class and putting it on each method is highly non-optimal because of the maintenance issue that would be created.

The QueryableAttribute should recognize the docoration on the call and not throw if the method has a parameter of type ODataQueryOptions.
Closed Jan 17 at 6:49 PM by hongyes
I have verified this scenario with latest code.

comments

HongmeiG wrote Oct 4, 2012 at 11:34 PM

We should open up an extensibility point in the Queryable attribute so that user can access ODataQueryOptions.

youssefm wrote Oct 30, 2012 at 9:52 PM

Hi Geminiman,

I think you'll find that the new extension method

HttpConfiguration.EnableQuerySupport()

addresses your concerns. This method applies the [Queryable] attribute to all actions that return IQueryable<T> except those that take an ODataQueryOptions parameter. So you can implement your own custom filtering on actions that take in ODataQueryOptions, while having a single line that enables querying across your application.

Geminiman wrote Nov 1, 2012 at 1:03 PM

How does one tell the EnableQuerySupport function to use my version of the Queryable attribute instead of the default one?

I still need to back fill $select until you guys finally get around to it.

hongyes wrote Jan 16 at 10:29 PM

Geminiman, EnableQuerySupport has an override that accepts an IActionFilter. You can set your custom queryable attribute there.

If you have ODataQueryOptions parameter in your action, the global filter won't be applied on it.