简体   繁体   English

如何从 azure 表存储中编写组合查询?

[英]How to write combined query from azure table storage?

I am trying to query from a table so that the name and partition key (combined) unique.我正在尝试从表中查询,以便名称和分区键(组合)唯一。 I am doing this right now:我现在正在这样做:

public Spec(string name)
{
    Query = new TableQuery<TableEntity>()
        .Where(TableQuery.GenerateFilterCondition(nameof(table.Name), QueryComparisons.Equal, name));
}

but I also need to check partition key exists withing this name.但我还需要检查此名称是否存在分区键。 So need to query the table along with the partition key and the name.所以需要查询表连同分区键和名称。 Can anybody help with this?有人可以帮忙吗? How to query these as combined query.如何将这些查询为组合查询。

Please try something like below:请尝试以下方法:

public Spec(string name)
{
    var filterCondition1 = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "PartitionKeyValue");
    var filterCondition2 = TableQuery.GenerateFilterCondition(nameof(table.Name), QueryComparisons.Equal, name);
    Query = new TableQuery<TableEntity>()
        .Where(TableQuery.CombineFilters(filterCondition1, "AND", filterCondition2));
}

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

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