0

I want to fetch records from azure table storage on the basis of multiple Partition key values.

I was referring below link for query data with multiple criteria:

Querying Windows Azure Table Storage with multiple query criteria

enter image description here

In above image as you can see that there are four records in the table now I want to fetch record based on two partition key values. for example I want to fetch record based on section1 and section2 partition key value.

So my question is can I write a single statement like TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "**section1, section2**"); like we write in SQL query.

or we need to write GenerateFilterCondition multiples time for each search criteria.

1 Answer 1

4

So my question is can I write a single statement like TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "section1, section2"); like we write in SQL query.

or we need to write GenerateFilterCondition multiples time for each search criteria.

As of today, Azure Table Service does not support IN like SQL databases so you would need to write multiple filter conditions connected by OR logical connector. For example,

        var pk1Filter = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "section1");
        var pk2Filter = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "section2");
        var pk3ilter = = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "section3");
        var filter = TableQuery.CombineFilters(pk1Filter, TableOperators.Or, TableQuery.CombineFilters(pk2Filter, TableOperators.Or, pk3Filter);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.