Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Mobile Service query doesn't return all the rows

I have a table called NameTable in my Azure Mobile Service. When I make the below mentioned calls in my client app (WP8 app using the Mobile Services SDK):

var myTable = GetZumoService().GetTable<NameTable>();
var myList = await myTable.Where(nameInfo => nameInfo.IsTaken == false).ToListAsync();

myList always contains only 50 items although I know that there are more than 400 rows in the tables that match the query condition.

What am I doing wrong?

like image 735
Raman Sharma Avatar asked Dec 30 '12 05:12

Raman Sharma


2 Answers

By default the service will only return a certain number of rows in each Read operation (50, as you noticed). Since there are quotas for the number of returned bytes in Azure services when they're free (and costs for paid ones), the mobile service has this default.

You can ask for more rows, using the Take operation. There is, however, a limit on the number of rows which you can ask at any given time (which is 1000). The idea is that you shouldn't ask for all data in a table - it can potentially be a lot - and ask for rows as you need them using the Skip and Take operations.

var myTable = GetZumoService().GetTable<NameTable>();
var myList = await myTable.Take(500)
                          .Where(nameInfo => nameInfo.IsTaken == false)
                          .ToListAsync();
like image 53
carlosfigueira Avatar answered Nov 20 '22 01:11

carlosfigueira


I found that this was not enough. You need to decorate your Azure Mobile Service controller method with the [EnableQuery] attribute as follows:

[EnableQuery(PageSize=1000)]
public IQueryable<MyDataTable> GetOneThousandRecords()
{
    return Query()
}
like image 8
NER1808 Avatar answered Nov 20 '22 00:11

NER1808