I am trying to have a function to map the Datatable single row to a class, and then return that class
here is my try,
c# Code:
  1. public T GetDataSingle<T>( Type ClassName,
  2. String UDP,
  3.  List<MySqlParameter> ParamCollection = null)        {
  4. // get the dataatble
  5.             DataTable ResultSet = new DataTable();
  6.             ResultSet = GetDataTable(UDP: UDP, ParamCollection: ParamCollection);
  7.  
  8. // the class to which i wanted to append the values
  9.             Type ty = ClassName.GetType();
  10.             PropertyInfo[] P = ty.GetProperties();
  11.             string PropertyName;
  12.  
  13.  
  14.             if(ResultSet != null && ResultSet.Rows.Count > 0)
  15.             foreach (var Property in P.ToList())
  16.             {
  17.                 PropertyName = Property.Name;
  18.  
  19.  
  20.                 foreach (DataColumn Dc in ResultSet.Columns)
  21.                 {
  22.                     if(Dc.ColumnName == PropertyName)
  23.                     {
  24.                         Property.SetValue(ClassName, Convert.ChangeType( ResultSet.Rows[0][Dc.ColumnName],Property.PropertyType));
  25.                     }
  26.                 }
  27.  
  28.  
  29.             }
  30. // what i should return here ,
  31. // i missed the road here
  32.             return Convert.ChangeType(ClassName, T);
  33.         }