mobileServiceTable.includeTotalCount() in html Javascript
mobileservicetable.includetotalcount();
why returns record getting count. performance flaw.
calling includetotalcount() instructs client ask server return count of items returned if no paging (skip / take) options used. if don't use paging options, includetotalcount indeed match number of items returned, not performant.
for example, in code below return total count, since no paging options specified, actual count of items returned same total count.
var client = new windowsazure.mobileserviceclient(url, key); var table = client.gettable('todoitem'); table.includetotalcount().read().then(function(results) { var totalcount = results.totalcount; var actualcount = results.length; });
now, if paging (see below), values potentially different - if have 40 items in table, results.length 10 (because of 'take' call) , totalcount 40.
var client = new windowsazure.mobileserviceclient(url, key); var table = client.gettable('todoitem'); table.take(10).skip(10).includetotalcount().read().then(function(results) { var totalcount = results.totalcount; var actualcount = results.length; });
can check tutorial @ http://www.windowsazure.com/en-us/develop/mobile/tutorials/add-paging-to-data-html/ for more information on paging mobile service client.
carlos figueira
Microsoft Azure > Azure Mobile Apps
Comments
Post a Comment