Convert DataRow to Dictionary Using LINQ

I need to convert a DataRow to a dictionary using LINQ.

The code below will receive a DataRow, the next step - I need to convert it to a dictionary (ColumnName, RowVale)

var WorkWeekData = from data in mWorkWeekData.AsEnumerable () where data.Field<string> ("Code") == code select data; 
+5
source share
1 answer

This is definitely possible, yes:

 var dict = row.Table.Columns .Cast<DataColumn>() .ToDictionary(c => c.ColumnName, c => row[c]); 
+14
source

Source: https://habr.com/ru/post/1244173/


All Articles