public FAPG(FAPG obj) { PropertyInfo[] p = obj.GetType().GetProperties(); // get entity properties for (int i = 0; i < (p.Length); i++) { if (!p[i].PropertyType.Name.Contains("list") && !p[i].Name.Contains("arg")) p[i].SetValue(this, p[i].GetValue(obj, null), null); // set entity's property values to obj properties } }
private void FetchPGList(int id, IDBManager dbmgr) { string qryString = "SELECT f.FA, p.* FROM FAPG p INNER JOIN FALIST f ON f.FA_ID = p.FA_ID WHERE p.FA_ID = @fa_id ORDER BY p.PG"; FAPG item = new FAPG(); ArrayList list = new ArrayList(); PropertyInfo[] p = item.GetType().GetProperties(); dbmgr.CreateParameters(1); dbmgr.AddParameters(0, "@fa_id", id); dbmgr.ExecuteReader(CommandType.Text, qryString); while (dbmgr.DataReader.Read()) { item = new FAPG(); item = (FAPG)FetchObject(item, p, dbmgr); list.Add(item); } dbmgr.CloseReader(); _firearea.pglist = list; }