Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Great question.</p> <p>$inlinecount out of the box only works when you're sending back OData responses. The reason for this is that OData defines special fields in the data that XML and JSON don't define. So in OData a response might look like this:</p> <pre><code>{ "odata.metadata":"http://localhost:12345/odata/$metadata#Customers", "odata.count":"4", "value":[ ... ] } </code></pre> <p>Notice the wrapper with the "odata.count" property. This is different from the way the default XML and JSON formatters write out data because they don't have wrappers for this additional information. So other formatters are by default unchanged.</p> <p>Now you have several options:</p> <p>You could choose to use the OData format. For this, you'll want to follow the instructions in this blog post:</p> <p><a href="http://blogs.msdn.com/b/webdev/archive/2013/01/29/getting-started-with-asp-net-webapi-odata-in-3-simple-steps.aspx">http://blogs.msdn.com/b/webdev/archive/2013/01/29/getting-started-with-asp-net-webapi-odata-in-3-simple-steps.aspx</a></p> <p>You could also choose to instead return a <code>PageResult&lt;T&gt;</code>. This looks like this:</p> <pre><code>public PageResult&lt;Customer&gt; Get(ODataQueryOptions&lt;Customer&gt; queryOptions) { IQueryable results = queryOptions.ApplyTo(_customers.AsQueryable()); return new PageResult&lt;Customer&gt;(results as IEnumerable&lt;Customer&gt;, Request.GetNextPageLink(), Request.GetInlineCount()); } </code></pre> <p>This should work fine for OData, JSON, and XML by adding a wrapper object for XML and JSON that can include the Count and the next page link.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload