asp.net web api - ODataQueryOptions not being applied -


i may missing simple based on blog post: http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/supporting-odata-query-options should working. have following controller method:

public virtual iqueryable<dtoagent> get(odataqueryoptions<agent> options, bool includeinactive = false, bool includedeleted = false)     {         iqueryable<agent> agents = null;         if (includedeleted && includeinactive)         {             agents = agentrepository.findall();         }         else if (includedeleted)         {             agents = agentrepository.findby(a => a.ussistatus == "a");         }         else if (includeinactive)         {             agents = agentrepository.findby(a => !a.isdeleted);         }         if (agents == null)         {             agents = agentrepository.findbyexp(a => a.ussistatus == "a" && !a.isdeleted);         }         options.applyto(agents);         return agents.todtos<dtoagent>();     } 

when call ../api/agent?$top=10 returns results not 10. can see topqueryoption in options variable not appear applied. works if use [queryable] attribute top applied after db call trying avoid. calling enablequerysupport @ global level , have both nuget package , 2012.2 update installed. help.

you missing simple. when call applyto, doesn't mutate iqueryable, returns applied query. should work instead:

var queryresults = options.applyto(agents) iqueryable<agent>; return queryresults.todtos<dtoagent>(); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -