using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Dynamic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace MES.Service.util
|
{
|
public static class DataTableExtension
|
{
|
public static List<dynamic> ToDynamic(this DataTable dt)
|
{
|
var list = new List<dynamic>();
|
foreach (DataRow row in dt.Rows)
|
{
|
dynamic obj = new ExpandoObject();
|
var dict = (IDictionary<string, object>)obj;
|
foreach (DataColumn col in dt.Columns)
|
dict[col.ColumnName] = row[col];
|
list.Add(obj);
|
}
|
return list;
|
}
|
}
|
|
|
}
|