OData / WebApi

OData Web API: A server library built upon ODataLib and WebApi
https://docs.microsoft.com/odata
Other
854 stars 476 forks source link

[feature/netcore] ODataQueryOptions.Initialize should use another constructor for ODataQueryOptionParser #1380

Closed maximpashuk closed 6 years ago

maximpashuk commented 6 years ago

I am using Microsoft.AspNetCore.OData 7.0.0-Nightly201804111241 to play with ODataUriResolver.EnableNoDollarQueryOptions setting.

If I register in DI ODataUriResolver with EnableNoDollarQueryOptions = true this not work - ODataQueryOptions parameter in controller don't understand '?top=1', understand only '?$top=1'.

I tried to investigate this and I found that in method ODataQueryOptions.Initialize() constructor for ODataQueryOptionParser not passed IServiceProvider argument (context.RequestContainer should be passed as last argument I think).

Because of this ODataQueryOptionParser.Configuration property became not DI-aware. And later in ODataQueryOptionParser.TryGetQueryOption method Configuration property used to get EnableNoDollarQueryOptions option value - and it always false.

So please use another constructor for ODataQueryOptionParser that has IServiceProvider argument.

biaol-odata commented 6 years ago

@maximpashuk Support for optional $-sign for query is only available in master branch of WebAPI. And it is not released yet. Branch feature/netcore is under active development and doesn't have the parity with the WebAPI/master branch for this feature yet.

maximpashuk commented 6 years ago

In beta4 ODataUriResolver.EnableNoDollarQueryOptions works fine so I close my issue