我尝试将数据表转换为特殊格式的 JSON
DataTable中的数据如下
col1 col2 col3 col4
---------------------
A B c D1
A B c D2
A B c D3
尝试将其转换为对象数组,例如
class obj {
var col1;
var col2;
var col3;
list<string> col4;
}
我尝试使用 linq,但有点卡住了。
var result = from row in dt.AsEnumerable()
group row by new
{
c1 = row["col1"],
c2 = row["col2"],
c3 = row["col3"]
}
into section
select new
{
item = section.Key
};