score:4

Accepted answer

As you already stated in your question, the Skip method is not implemented in Windows Azure Table storage. This means you have 2 options left:

Option 1

Download all data from table storage (by using ToList, see abatishchev's answer) and execute the Skip and Take methods on this complete list. In your question you're talking about 500 records. If the number of records doesn't grow too much this solution should be OK for you, just make sure that all records have the same partition key.

If the data grows you can still use this approach, but I suggest you evaluate a caching solution to store all the records instead of loading them from table storage over and over again (this will improve the performance, but don't expect this to work with very large amounts of data). Caching is possible in Windows Azure using:

Option 2

The CloudTableQuery class allows you to query for data, but more important to receive a continuation token to build a paging implementation. This allows you to detect if you can query for more data, the pagination example on Scott's blogpost (see nemensv's comment) uses this.

For more information on continuation tokens I suggest you take a look at Jim's blogpost: Azure@home Part 7: Asynchronous Table Storage Pagination. By using continuation tokens you only download the data for the current page meaning it will also work correctly even if you have millions of records. But you have to know the downside of using continuation tokens:

  • This won't work with the Skip method out of the box, so it might not be a solution for you.
  • No page 'numbers', because you only know if there's more data (not how much)
  • No way to count all records

score:0

If paging is not supported by the underlying engine, the only way to implement it is to load all the data into memory and then perform paging:

var list = cityService.Get("0001I").ToList(); // meterialize
var result = list.Skip(x).Take(y);

score:-1

Try something like this:

cityService.Get("0001I").ToList().Skip(n).Take(100);

This should return records 201-300:

cityService.Get("0001I").ToList().Skip(200).Take(100);

score:-1

a.AsEnumerable().Skip(m).Take(n)

Related Articles