title: ASP.NET Web Api: Correct way to serve OData-queryable GET requests
body: <p>What is the right way to serve OData-queryable GET requests in ASP.NET Web Api? That may sound like a "what is better" question, but it should be a "what does work" question.</p>
  
  <p>Some assumptions:</p>
  
  <ul>
  <li>To enable OData-querying, you have to put the <code>Queryable</code> attribute to the action method that returns <code>IQueryable&lt;Model&gt;</code>. Therefore, you have to expose the domain model?</li>
  <li>The domain model uses Entity Framework 5 and has navigation properties. The XML and Json Serializers do not like the EF proxies, so you have to disable them for OData queries?</li>
  <li>The serializers pick up the navigation properties and serve them to the user.</li>
  </ul>
  
  <p>So if I have a <code>Category</code> type that has navigation properties for parent and children, the serializers complain that I have cyclic references, and I cannot get rid of this error.</p>
  
  <p>I have read that I should use DTOs, but HOW? How can I provide a <code>IQueryable&lt;DTOModel&gt;</code> to the user that will create the appropriate SQL for the database? Remember, I want to use <code>$filter</code> and the like.</p>
  
  <p>I just want to give the user a filterable list of Model objects without the serialized navigation properties.... but HOW?</p>