简体   繁体   English

您如何在azure表存储中查询多个分区键?

[英]How do you query for multiple partition keys in azure table storage?

I'm pretty lost as to how to implement this method in Azure Table Storage. 我对如何在Azure表存储中实现此方法一无所知。 (Notice: I'm pretty new to it) (注意:我对此很陌生)

public IList<string> GetUserConnections(int[] userIds)
{
    string[] result = userIds.Select(x => x.ToString()).ToArray();
    var queryResult = _table.CreateQuery<ConnectionEntity>().Where(n =>     result.Contains(n.PartitionKey));
    return queryResult.Select(n => n.RowKey).ToList();
}

I'm getting an error when executing the query. 执行查询时出现错误。

An exception of type 'System.NotSupportedException' occurred in
Microsoft.WindowsAzure.Storage.dll but was not handled in user code

Additional information: The method 'Contains' is not supported

Here's my ConnectionEntity. 这是我的ConnectionEntity。

public class ConnectionEntity:TableEntity
{
    public ConnectionEntity()
    {

    }

    public ConnectionEntity(int userId, string connectionId)
    {
        this.PartitionKey = userId.ToString();
        this.RowKey = connectionId;
    }
}

Is it possible to do a Contains operator? 是否可以执行“包含”运算符? I can't seem to find the documentation on such a query. 我似乎找不到此类查询的文档。 Should I consider making a batch query on the partition key? 我应该考虑对分区键进行批量查询吗?

Looking at your code I think the only way to do what you are doing is to read on all the records of that type and do your LINQ queries against the local collection. 查看您的代码,我认为要做的唯一方法是读取该类型的所有记录,并对本地集合执行LINQ查询。 As long as you have less then a few thousand records of this type this will be very fast, and depending on how often those records are modified you could make subsequent queries extremely fast with some sort of local cache. 只要您拥有的这种类型的记录少于几千条,这将是非常快的,并且根据这些记录被修改的频率,您可以使用某种本地缓存非常快速地进行后续查询。 If you have too many records of this type for this to be feasible you might need to reconsider your partitioning strategy, or the design of this portion of your app, such that it can query smaller subsets of data, perhaps by some partition key. 如果您对此类型的记录过多,那么您可能需要重新考虑您的分区策略或应用程序这一部分的设计,以便它可以通过一些分区键查询较小的数据子集。

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

相关问题 如何从 Azure 表存储中的分区键列表进行查询 - How can I query from a list of partition keys in Azure table storage 如何对 Azure 存储表行键和分区键进行编码? - How can I encode Azure storage table row keys and partition keys? Azure表存储模拟器将SOH字符附加到分区键和行键 - Azure Table Storage Emulator appending SOH character to Partition and Row Keys Azure表存储查询从错误的分区返回数据? - Azure table storage query returning data from wrong partition? 如何使用对 Azure 表存储的单个查询检索多种类型的实体? - How do I retrieve multiple types of entities using a single query to Azure Table Storage? 如何使用 Azure.Storage v12 中的 Azure KeyVault 密钥解密 blob - How do you decrypt blobs with Azure KeyVault keys in Azure.Storage v12 Azure表存储(Partition key row key),如何在同一个partition不同rowKey对应插入多个实体? - Azure table storage (Partition key row key), how to insert multiple entities in corresponding to same parttion and different rowKey? 如何使用Linq查询Azure存储表? - How do I query an Azure storage table with Linq? 具有功能的天蓝色表存储中的多个查询参数 - Multiple query parameter in azure table storage with function Azure表存储:如何仅通过分区键获取单个实体? - Azure table storage: How to get a single entity by a partition key only?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM