I have a number of cases where i do a query and get a datatable and convert it to either a:
Dictionary<string, string>
or
Dictionary<int, int>
or
Dictionary<string, [Someobject]>
i could create my own function with a loop but i wanted to see if there was any LINQ way of converting a datatable into a dictionary and just passing 2 lambdas for the key and value (similar like you can do with converting IEnumerable to dictionary
You can use AsEnumerable & ToDictionary:
For example, if you want a dictionary where keys are from col1 and values from col2: