c# - How to use OData to do pagination on azure table storage APIs? -


well requirement client side paging. i.e return set of records based on values($top, $skip) given client. based on below code, able use filter keyword , top or skip.

[httpget]         public pageresult<persisteduser> getallusers(odataqueryoptions options) {     tableservicecontext servicecontext = tableclient.getdataservicecontext();     servicecontext.ignoreresourcenotfoundexception = true;      cloudtablequery<persisteduser> users = servicecontext         .createquery<persisteduser>(tablenames.user)         .astableservicequery();          iqueryable<persisteduser> results = options         .applyto(users.asqueryable()) iqueryable<persisteduser>;      // manipulate results. add calculated variables collection etc      return new pageresult<persisteduser>(results, null, 0); } 

i not sure if correct way well. basic requirement have huge db, need return small set of entities @ time in efficient time. appreciate if provide code snippets.

i'm using same way , it's working fine.

few differences:

i have service layer expose entites. in services return iqueryable , apply o data filter.

    [authkey]     [get("api/brands/")]     public pageresult<brandviewmodel> getbrands(odataqueryoptions<brand> options)     {         var brands = (iqueryable<brand>)options.applyto(_brandservices.findbrands());          return new pageresult<brandviewmodel>(brandviewmodel.toviewmodel(brands), request.getnextpagelink(), request.getinlinecount());     } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -