Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies To:# OData WebApi v7 for aspnet webapi supported
OData AspNet WebApi V7# OData Webapi for Webapi supported
OData AspNet WebApi V6
In OData WebApi 5.7, we can ignore some query options when calling ODataQueryOption ApplyTo method, this is helpful when your OData service is integrate with other service that may already applied those query options.
Customize
public class MyEnableQueryAttribute : EnableQueryAttribute
{
public override IQueryable ApplyQuery(IQueryable queryable, ODataQueryOptions queryOptions)
{
// Don't apply Skip and Top.
var ignoreQueryOptions = AllowedQueryOptions.Skip | AllowedQueryOptions.Top;
return queryOptions.ApplyTo(queryable, ignoreQueryOptions);
}
}
Controller
[MyEnableQuery]
public IHttpActionResult Get()
{
return Ok(_products);
}
Result
Then your queryOption won't apply Top and Skip.