简体   繁体   English

查询多个实体的azure表

[英]Querying azure table for multiple entities

I'm writing azure application. 我正在写azure应用程序。 My questions concerns querying azure table for specific entities. 我的问题涉及查询特定实体的azure表。

Application stores statistics of words used by users. 应用程序存储用户使用的单词统计信息。 In table partitionkey is the language and row key is the word. 在表中,partitionkey是语言,行键是单词。

I need to query for multiple words. 我需要查询多个单词。 To speed up the process I want to pull in one query all relevant entities. 为了加快这个过程,我想在一个查询中提取所有相关实体。

I know how to 'batch insert' group of entities that have the same partitionkey. 我知道如何'批量插入'具有相同分区键的实体组。 How to query for like 50 diffrent entities with the same partitionkey but different rowkey. 如何查询具有相同分区键但不同rowkey的50个不同实体。

Is there possibility of specifying query as string ? 是否有可能将查询指定为字符串?

Regards 问候

You can specify up to 15 matches in your $filter , so essentially 15 specific rowkeys if you went down that route. 您可以在$filter指定最多15个匹配项,因此如果您沿着该路线走下去,则基本上会有15个特定的行键。 Note: This will result in a partition scan. 注意:这将导致分区扫描。 Specifics on querying are in this article . 查询的细节在本文中

There's more information in this StackOverflow question and related answers. StackOverflow问题和相关答案中有更多信息。

But one query would not necessarily speed it up. 但是一个查询不一定能加速它。 Issue 5 queries of 10 words each (possibly in parallel) and combine the results. 发出5个查询,每个查询10个单词(可能并行)并合并结果。

It's not the question you asked, but you may find that you'll get better performance out of this specific query if you reverse the RowKey and PartitionKey. 这不是你问的问题,但如果你反转RowKey和PartitionKey,你可能会发现你会从这个特定的查询中获得更好的性能。 I'm guessing that there could be quite a few words in a language so this will mean that you'll have quite large partitions. 我猜测一种语言中可能会有很多单词,所以这意味着你将拥有相当大的分区。 If you try to parallelise your query as suggested by others (which is a good idea) all of these queries will be hitting the same partition with your current key plan. 如果您尝试按照其他人的建议并行查询(这是一个好主意),所有这些查询将与您当前的密钥计划达到相同的分区。

If you did reverse the keys though it would mean that getting a list of words for a particular language will be really quite inefficient. 如果您确实反转了键,但这意味着获取特定语言的单词列表将非常低效。

I'm not aware of any easy way to do it, but there are some dynamic LINQ query libraries that you could use. 我不知道有任何简单的方法,但您可以使用一些动态LINQ查询库。

You might want to check out this question: 您可能想看看这个问题:
Parsing a string C# LINQ expression 解析字符串C#LINQ表达式

And these libraries: 这些库:
Dynamically generate a LINQ query with a custom property 使用自定义属性动态生成LINQ查询
Invent your own Dynamic LINQ parser 创建您自己的Dynamic LINQ解析器

And this tutorial: 本教程:
Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library) 动态LINQ(第1部分:使用LINQ动态查询库)

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

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