1

Closed

$Skip and $Top values are not aggregated when using ODataQueryOptions

description

Tested with Microsoft.AspNet.WebApi.OData.0.1.0-alpha-121009.

Assume the following simple controller:


public class ValuesController : ApiController
{
private int[] values = Enumerable.Range(1, 100).ToArray();

[Queryable]
public IQueryable<int> GetValues(bool flag)
{
    return values.AsQueryable();
}

public IQueryable<int> GetValues(ODataQueryOptions options)
{
    return options.ApplyTo(values.AsQueryable()) as IQueryable<int>;
}
}


The following action invocations result in skipping 3 records, then taking 30.

GET api/values?flag=true&$skip=7&$skip=3&top=20&top=30
GET api/values?$skip=7&$skip=3&top=20&top=30

Does it make sense to apply the aggregate of the $skip values, and take the min of the $top values? This would be consistent with how the equivalent linq query would behave. Currently, the implementation is only consuming the last value seen.
Closed Nov 26, 2012 at 10:44 PM by HongmeiG
I don't think OData spec accept this.

comments