title: How to map filter options from ODataQueryOptions to RestRequest
body: <p>I need to be able to convert from <a href="https://msdn.microsoft.com/en-us/library/system.web.http.odata.query.odataqueryoptions(v=vs.118).aspx" rel="noreferrer">ODataQueryOptions</a> to <a href="http://restsharp.org/" rel="noreferrer">RestRequest</a> in order to be able to issue a RestRequest with specified filters, and have created the following helper class:</p>
  
  <pre><code>public static class ODataQueryFilterToRestClient
  {
      public static RestRequest Map(ODataQueryOptions odataQuery)
      {
          var restRequest = new RestRequest();
  
          if (odataQuery.Filter != null)
          {
              restRequest.AddQueryParameter(@"$filter", odataQuery.Filter.RawValue);
          }
  
          if (odataQuery.Top != null)
          {
              restRequest.AddQueryParameter(@"$top", odataQuery.Top.RawValue);
          }
  
          if (odataQuery.Skip != null)
          {
              restRequest.AddQueryParameter(@"$skip", odataQuery.Skip.RawValue);
          }
  
          if (odataQuery.OrderBy != null)
          {
              restRequest.AddQueryParameter(@"$orderby", odataQuery.OrderBy.RawValue);
          }
          //etc
          return restRequest;
      }
  }
  </code></pre>
  
  <p>Given that OdataQueryOptions supports the following:</p>
  
  <p><a href="https://i.stack.imgur.com/otVWx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/otVWx.png" alt="enter image description here"></a></p>
  
  <p><strong>Is there a simpler way to make the conversion between ODataQueryOptions to RestClient, or another rest client proxy?</strong></p>
  
  <p>On a side note, I don't know <strong>if there's a better way to accept parameters through a controller than ODataQueryOptions?</strong></p>