1 public static IList<T> ReflectionToModelList(DataTable dt) 2 { 3 IList<T> list = new List<T>(); 4 if (dt == null || dt.Rows.Count < 1) 5 return list; 6 Type type = typeof(T); 7 foreach (DataRow dr in dt.Rows) 8 { 9 T model = new T(); 10 foreach (DataColumn dc in dt.Columns) 11 { 12 type.GetProperty(dc.ColumnName).SetValue(model, dr[dc.ColumnName], null); 13 } 14 list.Add(model); 15 } 16 return list; 17 }