dataset to Listusing linq

前端 未结 6 640
别跟我提以往
别跟我提以往 2021-02-06 13:18

I have a DataSet and I want to convert the DataSet into List

T - type object

How convert my DataSet?

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-06 13:56

    I think this should do it.

    var output = yourDataSet.Tables[0].Rows.Cast().Select(r => new
    {
        Column1 = r["Column1"].ToString(),
        Column2 = r["Column2"].ToString(),
        Column3 = r["Column3"].ToString(),
        Column4 = r["Column4"].ToString(),
        Column5 = r["Column5"].ToString(),
        Column6 = r["Column6"].ToString(),
        Column7 = r["Column7"].ToString(),
        Column8 = r["Column8"].ToString(),
        Column9 = r["Column9"].ToString(),
        Column10 = r["Column10"].ToString()
    }).ToList();
    

提交回复
热议问题