简体   繁体   English

如何从 azure 表存储查询中获取 1000 多个实体?

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

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.我读过 Azure 表存储查询最多提供 1000 个实体,我们必须使用延续令牌来获取下一组实体。 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.我想要做的就是获取查询应该实际返回的所有实体,而不仅仅是 1000 个实体。 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.我在这里阅读了@smarx 帖子,他提到了TableStorageDataServiceQuery ExecuteAll方法,但这似乎已被弃用,因为我在存储客户端库中找不到TableStorageDataServiceQuery

I also found this msdn documentation on how to handle the continuation tokens to fetch all the entities.我还找到了有关如何处理延续令牌以获取所有实体的msdn文档。 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?或者是否有任何我可以使用的 ExecuteAll esque 方法?

像这样使用 AsTableServiceQuery:

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

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.这有点奇怪 - 不是一个很好的长期解决方案 - 但我专门为 Linqpad 分叉了 Azure 存储驱动程序,以从表存储中获取所有记录。

https://github.com/ryan1234/AzureStorageDriver https://github.com/ryan1234/AzureStorageDriver

Get it, build it and install it with Linqpad.获取它,构建它并使用 Linqpad 安装它。 An example query that goes against it in Linqpad:在 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");

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.查询表存储的方法有很多,但最简单的方法是创建一个CloudTable对象,创建一个TableQuery对象,然后在传入TableQuery对象的CloudTable对象上调用ExecuteQuery。

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. 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=eb5a88d975df445ab665fbf5082fa77的第一个结果您可以访问 http://www.windowsazure.com/en-us/develop/net/how-to-guides/table-services/ ,其中显示了如何执行此操作的示例。

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.请注意,即使记录数 < 1000,也可以返回延续令牌。在执行查询时始终检查延续令牌是个好主意。

Also, why do you want to return more than 1000 records?另外,为什么要返回1000多条记录? what is the use case?用例是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM