title: How to manually populate ODataQueryOptions from a oData query string in an ordinary ApiController?
body: <p>I am using an ApiController (not an ODataController) with OData v4, in which there is a Get action taking ODataQueryOptions as a parameter, like the following:</p>
  
  <pre><code>public Product[] Get(ODataQueryOptions&lt;Product&gt; queryOptions){
      // Do query ...
  }
  </code></pre>
  
  <p>When I send the oData query request to the ApiController as a uri via web api call, the ODataQueryOptions will be automatically populated. However, when the query string is very long, I get exceptions. I believe the exceptions are caused by that the length of the uri exceeds the limit. I am thinking about passing over the odata query string via the request body, instead of via the uri directly, hoping to bypass the uri length limit problem. E.g.,</p>
  
  <pre><code>public Product[] Get([FromBody] uriString){
      // var oDataQueryOptions = SomeMethod(uriString);
      // Do query ...
  }
  </code></pre>
  
  <p>It seems one can construct ODataQueryOptions using ODataQueryContext and HttpRequestMessage:</p>
  
  <pre><code>public ODataQueryOptions(
      ODataQueryContext context,
      HttpRequestMessage request
  )
  </code></pre>
  
  <p>ODataQueryContext in turn can be constructed using </p>
  
  <pre><code>public ODataQueryContext(
      IEdmModel model,
      Type elementClrType,
      ODataPath path
  )
  </code></pre>
  
  <p>I am able to get the model (IEdmModel) and elementClrType (Type). However, I don't know how to get ODataPath from the query uri.</p>
  
  <p>Also, can I construct a HttpRequestMessage using the uri string (which might be very long)?</p>
  
  <p>Again, I am using an ordinary ApiController with OData V4.</p>
  
  <p>Any help will be greatly appreciated!</p>