示例#1
0
 /// <summary>
 /// Convert this SourceList to DataTable instance.
 /// DataTable.Columns are the name of the properties in each list item.
 /// </summary>
 public static System.Data.DataTable ToDataTable(this System.Collections.IList SourceList, string TableName)
 {
     System.Data.DataTable table = new System.Data.DataTable(TableName);
     if (SourceList.Count > 0)
     {
         foreach (var item in MemberInfox.GetMemberInfox(SourceList[0]))
         {
             table.Columns.Add(item.Name, item.MemberType);
         }
         table.Populate(SourceList);
     }
     return(table);
 }