I am using this, which seems like what you need:
EDITED thanks to Heinzi
public virtual void LoadDataRow(DataRow drow, params string[] parameters) { this.LoadDataRow(drow); foreach (string property in parameters) { try { if (drow[property] != null) { PropertyInfo pi = this.GetType().GetProperty(property); if (pi != null && drow.Table.Columns.Contains(property)) { pi.SetValue(this, drow[property], null); } } } catch { throw; } } }
In your case, however, you can first skip the first eproperty collection of your object and try loading from your dataset, but you need to start with this code.
EDIT
This is detected on MSDN:
System.Reflection.PropertyInfo[] p = MyObject.GetType.GetProperties(); foreach(System.Reflection.PropertyInfo prop in p) { .... }
source share