List to DataTable
===

I want to convert List to DataTable(). I have List<employee> and I have properties as List<string> and Dictonery<string,string> inside that. How can I convert to ToDataTable().


My code is as follows From this code I can convert only System.Int,System.String but I am unable to convert Syste.Collections also. Actually I want the rows to be duplicated with every value of inner list or dictinery.


         public class Program 
         {
                 static void Main(string[] args)
           {
            Employee ee = new Employee();
            ee.Age = 98;
            ee.Name = "adfa";


            List<string> adad = new List<string>();
            adad.Add("adad");
            adad.Add("1212adad");
            adad.Add("59adad");

            Dictionary<string, string> dfasd = new Dictionary<string, string>();
            dfasd.Add("adad", "adfad");
            dfasd.Add("qwqq", "mnmn");

            ee.lstCer = adad;
            ee.kkj = dfasd;

            List<Employee> lschk = new List<Employee>();
            lschk.Add(ee);


	    Program ps = new Program();
            DataTable dt = ps.ToDataTable(lschk); 
         }
               public DataTable ToDataTable<T>(IList<T> data)
          {
            PropertyDescriptorCollection properties =
                TypeDescriptor.GetProperties(typeof(T));
            DataTable table = new DataTable();

           
            foreach (PropertyDescriptor prop in properties)
            {
               
                table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
            }
            DataRow row = null;
            foreach (T item in data)
            {
              
                foreach (PropertyDescriptor prop in properties)
                {
                   
                        row[prop.Name] = prop.GetValue(item) ?? DBNull.Value;
                  
                }
                table.Rows.Add(row);
            }
            return table;
        } 
}

            public class Employee
      {
        public string Name { get; set; }
        public int Age { get; set; }
        public List<string> lstCer { get; set; }
        public Dictionary<string, string> kkj { get; set; }
        public Array hh { get; set; }
      }

  