2

Can not pass two parameter on azure table storage within azure function.

What I have tried:

My parameter on function:

        // convert all request perameter into Json object
        var content = req.Content;
        string jsonContent = content.ReadAsStringAsync().Result;
        dynamic requestPram = JsonConvert.DeserializeObject<Product(jsonContent);


        // extract each param
        string product = requestPram.product;

        string version = requestPram.version;

My storage query

 var query = new TableQuery()
                {
                    FilterString = TableQuery.GenerateFilterCondition("ProductName", QueryComparisons.Equal, product),
                    SelectColumns = new string[] {
                    "ProductName","EntitledProductsCurrentPrevious","MainstreamSupportEndDate"
                },
                    TakeCount = 200
                };

Here I have passed on param "product" Its work fine and return expected data. but I want to pass also version . Similar like sql WHERE product = 'proudctname' and version = 'versionName'

Just Like following TSQL

SELECT Product,EntitledProductsCurrentPrevious,MainstreamSupportEndDate 
FROM BotProductList 
WHERE Product = 'Microsoft Dynamics CRM' AND 
EntitledProductsCurrentPrevious = '2016'

I have followed below reference:

reference_1

reference_2

reference_3

But Still cannot solve it.

Any help will be appreciated.

Md Farid Uddin Kiron
  • 16,817
  • 3
  • 17
  • 43

2 Answers2

2

Try string finalFilter = TableQuery.CombineFilters(productQuery, TableOperators.And, versionQuery); instead.

Zhaoxing Lu
  • 6,319
  • 18
  • 41
  • You're welcome. Your code below also works since it directly constructs the query string. – Zhaoxing Lu Apr 17 '19 at 14:23
  • Yeah, Also query string need not to convert on storage environment as it can directly be run there on the other hand linq needed to be convert each time which sometimes a little costly. – Md Farid Uddin Kiron Apr 18 '19 at 01:44
2

After many struggling I have solved this problem in below format:

var query = new TableQuery()
                {
                    FilterString = string.Format("PartitionKey eq '{0}' and RowKey eq '{1}'", product, version),
                    SelectColumns = new string[] {
                    "ProductName","EntitledProductsCurrentPrevious","MainstreamSupportEndDate"
                },
                    TakeCount = 200
                };

It also reduced some line of code.

Md Farid Uddin Kiron
  • 16,817
  • 3
  • 17
  • 43