参考下
public static List <T> DataTableToObject <T>(List <T> xtraList, DataTable xtraDataTable) where T : new()
    {
            xtraList = new List <T>();
            foreach (DataRow dr in xtraDataTable.Rows)
            {
                    T _t = new T();
                    Type _type = _t.GetType();
                    foreach (DataColumn dc in xtraDataTable.Columns)
                    {
                        PropertyInfo info = _type.GetProperty(dc.ColumnName);
                        info.SetValue(_t, dr[dc.ColumnName], null);
                    }
                    xtraList.Add(_t);
            }
            return xtraList;
    }

相关文章:

  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 2022-12-23
猜你喜欢
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
  • 2021-06-13
  • 2022-02-18
  • 2022-02-01
  • 2022-12-23
相关资源
相似解决方案