简体   繁体   中英

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));
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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