How to get more than 1000 entities from an azure table storage query?

六眼飞鱼酱① 提交于 2019-11-28 06:22:11

问题


I have read that azure table storage queries give maximum of 1000 entities and we have to make use of continuation tokens to fetch the next set of entities. I am just looking for an easy way to do that. All I want to do is fetch all the entities that the query should actually return and not just the 1000 entities. I have read @smarx post here and he mentions about ExecuteAll method in TableStorageDataServiceQuery but this seems to have deprecated as I cant find TableStorageDataServiceQuery in the storage client library.

I also found this msdn documentation on how to handle the continuation tokens to fetch all the entities. I just want to know if this is the best way to get all the entities, I dont need any pagination. Or is there any ExecuteAll esque method that I can use?


回答1:


Using the AsTableServiceQuery like so:

var data = context.CreateQuery<SomeEntity>("table").AsTableServiceQuery<SomeEntity>().Execute();



回答2:


There are lots of ways to query table storage, but the easiest way is to create a CloudTable object, create a TableQuery object, then call ExecuteQuery on the CloudTable object passing in the TableQuery object.

The first result from http://www.bing.com/search?q=azure+table+storage+query&qs=n&form=QBRE&pq=azure+table+storage+query&sc=8-25&sp=-1&sk=&cvid=eb5a88d975df445ab665fbf5082fa7c8 will take you to http://www.windowsazure.com/en-us/develop/net/how-to-guides/table-services/ which shows examples of how to do this.




回答3:


It's a bit grotesque - and not a great long term solution - but I forked the Azure Storage Driver for Linqpad specifically to get all records from table storage.

https://github.com/ryan1234/AzureStorageDriver

Get it, build it and install it with Linqpad. An example query that goes against it in Linqpad:

var logs = (from log in SBEmailWorkerRole.ToList()
            select new {
                LogEntry = log.LogEntry,
                CreateDate = log.Timestamp.ToLocalTime()
            }).ToList();

logs.OrderByDescending(l => l.CreateDate).Dump("Logs");



回答4:


If my understanding of documents is correct, there is no way to do that.

Please be aware that continuation tokens can be returned even when number of records < 1000. It is a good idea to always check for continuation tokens when executing queires.

Also, why do you want to return more than 1000 records? what is the use case?



来源:https://stackoverflow.com/questions/18615673/how-to-get-more-than-1000-entities-from-an-azure-table-storage-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!