[英]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.