[英]How do you query for multiple partition keys in azure table storage?
我对如何在Azure表存储中实现此方法一无所知。 (注意:我对此很陌生)
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();
}
执行查询时出现错误。
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
这是我的ConnectionEntity。
public class ConnectionEntity:TableEntity
{
public ConnectionEntity()
{
}
public ConnectionEntity(int userId, string connectionId)
{
this.PartitionKey = userId.ToString();
this.RowKey = connectionId;
}
}
是否可以执行“包含”运算符? 我似乎找不到此类查询的文档。 我应该考虑对分区键进行批量查询吗?
查看您的代码,我认为要做的唯一方法是读取该类型的所有记录,并对本地集合执行LINQ查询。 只要您拥有的这种类型的记录少于几千条,这将是非常快的,并且根据这些记录被修改的频率,您可以使用某种本地缓存非常快速地进行后续查询。 如果您对此类型的记录过多,那么您可能需要重新考虑您的分区策略或应用程序这一部分的设计,以便它可以通过一些分区键查询较小的数据子集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.