Use LINQ query from Datatable and convert to Dictionary

Hi there,
I’m finding best practice to convert Datatable to Dictionary.
Now I use script as below,

  1. Create => Dictionary
  2. Create => Temp datatable as “dtTemp”
  3. Query with LINQ and store value into “dtTemp”
  4. Finally, use method .ToDictionary()
    image

I need to know, Is there a solution without create “dtTemp” to store value when query.

can you share some sample data and expected output? thanks

Also give a try at:

Assign Activity:
dict_TypeFromOutstanding | DataType: Dictionary(Of String, String) =

(From d in in_dtInput.AsEnumerable
Group d by k=d(24).toString.Trim into grp=Group
Let ot = IF(grp.Sum(Function (g) Convert.ToDouble(g(74).toString)) >=0, "TypeA", "TypeB")
Select t = Tuple.Create(k,ot)).ToDictionary(Function (x) x.Item1,Function (x) x.Item2)

Wow so fast, Thank you sir !

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