public MUser DataAssigner(DataTable dt, MUser user) { foreach (DataRow dr in dt.Rows) { int i = 0; foreach (DataColumn dc in dr.Table.Columns) { PropertyInfo pi = user.GetType().GetProperty(dc.ColumnName); pi.SetValue(user, dc.Table.Rows[0][i], null); i++; } } return user; }