title: How can I convert OData to ServiceStack AutoQuery?
body: <p>I have a Web API project that uses OData to query the database. But now I want to transform this project using ServiceStack AutoQuery. The problem is that I <strong>don't</strong> have access to the frontend. So the incomming requests are using the OData filter expressions. Is there a way to transform the ODataQueryOptions so I can query that database using AutoQuery or OrmLite?</p>
  <p><strong>Edit (@mythz):</strong></p>
  <p>so I should transform the url to an OrmLite query? For example:</p>
  <pre><code>Categories?$filter=(Id eq 11) and (Deleted eq false)&amp;$expand=CategoryTranslations
  </code></pre>
  <pre class="lang-cs prettyprint-override"><code>[HttpGet]
  public IQueryable&lt;Category&gt; Categories(ODataQueryOptions odataQueryOptions)
  {
      var query = ErpDb.From&lt;Category&gt;();
  
      #region ordering
  
      if (odataQueryOptions.OrderBy != null)
      {
          query.UnsafeOrderBy(odataQueryOptions.OrderBy.RawValue);
      }
  
      #endregion
  
      #region paging
  
      var inlineCount = ErpDb.Count(query);
  
      if (odataQueryOptions.Skip != null)
      {
          query.Skip(odataQueryOptions.Skip.Value);
      }
  
      if (odataQueryOptions.Top != null)
      {
          query.Take(odataQueryOptions.Top.Value);
      }
  
      #endregion
  
  
      ...
  }
  
  </code></pre>