WebApi icon indicating copy to clipboard operation
WebApi copied to clipboard

ODataQueryOptions should allow duplicate non-OData query options

Open bitsforthought opened this issue 11 years ago • 7 comments

Our Web API exposes both OData and custom query options. Some of our query options allow duplicate values, but the ODataQueryOptions constructor throws an exception when it detects any duplicate query options (not just standard OData query options). This requires us to maintain a lot of code to work around this issue that we would rather not have to maintain.

WebAPI should have no opinions on whether it is valid to have duplicate custom query options. A Dictionary should only be used to hold OData query options, not custom query options. See this line in the ODataQueryOptions constructor:

        IDictionary<string, string> queryParameters =
            request.GetQueryNameValuePairs().ToDictionary(p => p.Key, p => p.Value);

bitsforthought avatar Jun 25 '15 04:06 bitsforthought

Pre-process the name value pairs, before creating the dictionary.

congysu avatar Jul 15 '15 07:07 congysu

relay on ODL https://github.com/OData/odata.net/issues/375

VikingsFan avatar Nov 11 '15 02:11 VikingsFan

Related issue: https://github.com/OData/odata.net/issues/245.

TomDu avatar Apr 28 '16 09:04 TomDu

Merged for 6.x, need merge in 5.x when OData 5.x include this fix. a10881f462d24bca53a5373d9d3e64a3df9f7e2b

VikingsFan avatar Aug 08 '16 07:08 VikingsFan

@VikingsFan Hey - I just ran into this problem today. We're on .NET 4.6.1 and so I can't upgrade to OData 6.0.0 (due to the dependency injection framework). Is there any chance that this will be backported to the 5.9.x branch?

Thanks!

jwahyoung avatar Jan 30 '17 20:01 jwahyoung

@xuzhg This issue appears to have been fixed, at least in 7.x. Can this issue be closed?

bitsforthought avatar Dec 15 '18 00:12 bitsforthought

Closing this issue. If this still affects the latest versions of the library, kindly open a new issue.

habbes avatar Mar 01 '22 07:03 habbes