2012-08-13 32 views
1

我在Azure調用中使用.AsTableServiceQuery()來獲取數據。

我也用$top得到的資料有限,可以說100

的問題是,查詢返回100個結果,它也會給x-ms-continuation-NextPartitionKey令牌。 同時.AsTableServiceQuery()不關心已經有100個結果,並且繼續令牌直到達到表的結尾。以後有很多數據和大量的HTTP調用,超時。

是否有任何其他的方法來處理延續令牌與$top濾波器

回答

3

延續令牌是混亂的典型源。無論何時您發出$ filter或$ top,最好指望延續令牌。 $ top是對錶格進行分頁的另一種方式。使用Linq Take(n)後面跟着.AsTableQuery()按照您期望的方式工作。 Neil Mackenzie在他非常具有描述性的博客文章中給出了一個很好的示例。

CloudTableQuery<Song> cloudTableQuery = 
(from entity in tableServiceContext.CreateQuery<Song>(「Songs」) 
select entity).Take(10).AsTableServiceQuery<Song>(); 
+0

謝謝,在改變'.AddQueryOption(「$ top」,'to'.Take()'後,問題就神奇地消失了。 – 2012-08-13 00:39:47