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.
CodePudding user response:
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));
}