Link Query for conditions

Hi All,

I have my Data Table consisting of column name s “Charges” and “List Price”

from my Data Table I need to build query for the following conditions:

Condition 1 check If column value "Charges " is equal to variable "sku_name " and column value “ListPrice” is equal to variable value “sku_list_price” then run the process1

Else If column value "Charges " is equal to variable "sku_name " and column value “ListPrice” is Not qual to variable value “sku_list_price” then run the process2

@dutta.marina,

Try these LINQ

' Process1: Rows where "Charges" = sku_name and "ListPrice" = sku_list_price 
process1Rows = From row In dataTable.AsEnumerable() Where row.Field(Of String)("Charges") = sku_name AndAlso row.Field(Of String)("ListPrice") = sku_list_price Select row 

' Process2: Rows where "Charges" = sku_name and "ListPrice" <> sku_list_price 
process2Rows = From row In dataTable.AsEnumerable() Where row.Field(Of String)("Charges") = sku_name AndAlso row.Field(Of String)("ListPrice") <> sku_list_price Select row

Hi @dutta.marina

Running the process means do you want to check each row value or do you want to segregate into two datatables like Process1 and Process2.

Could you be more specific.

@mkankatala

I want to check row value

@ashokkarale

I need to put in If condition something like this and check. I tried using for each loop but there are more than 200 rows and it takes long time to check each row hence wanted to use Linq query

Hi @dutta.marina

Do you want to find the count of spesific rows based on the conditions only? Or do you want to find the rows and update them?

If you want to find the count, you should use “Any” function like below:

ExtractDataTable.AsEnumerable.Any(Function (x) x.Item(“Charges”).ToString=sku_name and x.Item(“List price Quantity”).ToString=“sku_listprice”)

You can use the expression in “If” activty.

Hope this helps,
Regards.