Can someone help me to check if the value say “item”(this belongs to a particular name column in a datatable) is present in a dictionary(name, email).
If it belongs , then i have to extract that particular row and add to a newly created list which is of type datarow
Hello @shilpa_p ,
You can use this in the if condition inside for each row to check if value is present in your dictionary:
If it contains, you can add the row to your list/array using “Add To Collection” activity.
I shall try this
Sure! Please try and let me know
Hi @shilpa_p ,
Let’s say we have the following the variables :
DT as a Datatable variable,
item as a String,
dictVar as a Dictionary,
dataRowList as List of DataRow.
- Checking the Item is Present in the Dictionary. Assuming that we are Checking the name, which is the
Key in Dictionary we can do the following by Specifying the condition below in an
if the Check is for the Values, we can use the below Expression :
- In the Then Part, we can get the Matching DataRow from Datatable using an Assign Activity in the below way :
arrayRow = DT.AsEnumerable.Where(Function(x)x("Name").ToString.Trim.Equals(item.ToString.Trim)).ToArray
arrayRow is a variable of Type Array of DataRow
- Next, we can Check if
arrayRow has any values using an
If Activity with Condition in the below way :
- In the Then Part of If, we can Add the DataRow to the List of DataRows using an Invoke Method Activity.
Using a For Each to Loop through the Collection of Matched DataRows, add to the List of DataRows, Like Below :
Let us know if you are facing any difficulties while performing the above methods
Thank you so much.
I will try this as well. I guess it will work for me. I shall update you
@shilpa_p , We would also need to make sure the
dataRowList is initialised, Hence, We do the following at the beginning, or as a Default value for the variable :
dataRowList = new List(Of DataRow)
Thank you so much . It worked
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.