Feed a LINQ result into a DataROW

后端 未结 3 1714
一向
一向 2021-01-03 11:37

This works:

var Result = from e in actual.Elements
                         select new
                         {
                             Key = e.Key,
          


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-03 12:17

    You might want to look into the DataTableExtensions.AsEnumerable Method

    I haven't tested this, but this might get you pointed in the right direction:

    IEnumerable result = (from e in actual.Elements
                                  select new DataRow
                                  {
                                      Key = e.Key,
                                      ValueNumber = e.Value.ValueNumber,
                                      ValueString = e.Value.ValueString,
                                      ValueBinary = e.Value.ValueBinary,
                                      ValueDateTime = e.Value.ValueDateTime
                                  }).AsEnumerable();
    
    DataTable dt = Result.CopyToDataTable(Result);
    

提交回复
热议问题