Search code examples
restapiodata

Fetching the Odata query parameter in code


I have a rest Get method Ex:-

public IQueryable<Test> GetTest() {
            return _service.GetAll();
        }

I want to fetch the query parameter in code which was the part of the request url, I cant give OdataQueryOption parameter in the method like GetTest(OdataQueryOption op).

Please suggest a solution


Solution

  • Assuming you're implementing an ODataController you should be able to access this.Request.RequestUri.Query. If you want the name/value pairs you should use System.Web.HttpUtility.ParseQueryString to get a NameValueCollection.