Convert DataRow to Dictionary of Key Value

I am reading data from excel using Read Range activities and doing data entry for each row item retrived from data row. As I have current 10-12 columns and I have to pass these values to multiple workflows I would like to know if there is a way to convert the data row into a dictionary of (Columnname,Value ) so that I could just pass the dictionary between workflows instead of 10-12 variables.

Please need urgent replies

Use “Add to Dictionary” activity to add the Key and value in the Dictionary.

Note: Install the package Microsoft.Activities.Extensions, then only these activities will appear in activities window.

Not sure if this is exactly the same what you want, have a look


Can you share xaml file for the above one

This can be done with LINQ
Lets assume the first row schould be converted, following statement can be used:

dtSample.Rows(0).ItemArray.Select(Function (item, index) new KeyValuePair(Of String, Object)(dtSample.Columns(index).ColumnName, item)).toDictionary(Of String, Object)(Function (d) d.Key, Function (d) d.Value)

sharing simplified statetement and demo XAML:
YourDataTableVar.AsEnumerable.ToDictionary(Of String, String)(Function (r) r(YourKeyCol).toString, Function (r) r(YourValueCol).toString)


Thanks but still can i have the complete flow

thanks, you saved my day :slight_smile:

It might be too late, but it might serve for someone else in the future. I was having kind of the same issue, I needed to convert an “n” amount of columns into a “n” amount of key pairs to add into a dictionary, my solution is this:

Inside of a “For Each row in DataTable”.
Into an assign activity, to a variable type Dictionary(of string, object), I assigned:

(From column As DataColumn In row.Table.Columns.Cast(Of DataColumn)()
Select Key = column.ColumnName, Value = row(column.ColumnName)).ToDictionary(Function(x) x.Key, Function(x) x.Value)

As you can see the key will be de column name and de value will be the row value in that column.


This was useful for me in order to serialize this dictionary as a json and put this in a queue item. Lets see what this will bring when the moment comes for the performer to handle this element. Anyway, thanks for sharing your knowledge.