Problem in Dictionary

I have one value in String and another in Number.
I wanto get the DataTable as Dictionary

Help me out.

Hi @SP_Bot

Your query is little confusing, can you elaborate.

Regards

@Parvathy
I have Datatable with one value in string and another is of Number.
Need Linq Query to convert it into Dictionary

Hi @SP_Bot

  1. Use Read Range Activity (Here I’m using Build DataTable) & Store in Variable DT
  2. Use Assign Activity and use below expression
    Note: Dictionary(of String, Object) Type

DT.AsEnumerable.ToDictionary(Function(x) x("Key").ToString, Function(y) y("Value"))


image



Hope it’ll helps you :slight_smile:
Cheers!!

1 Like

Hi @SP_Bot

Try this query:

dtDictionary.AsEnumerable().ToDictionary(Of String, Integer)(Function(row) row.Field(Of String)("StringColumn"), Function(row) Convert.ToInt32(row.Field(Of Object)("NumberColumn")))

Output DataType is System.Collections.Generic.Dictionary(Of String, Integer)

Hope it helps!!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.