public FZProtection(FZProtection 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 FetchProtectionList(int id, IDBManager dbmgr) { string qryString = "SELECT * FROM viewFZPROTECTION WHERE FA_ID = @fa_id ORDER BY FZ, SYS_CATEGORY, SYS_NAME"; FZProtection item = new FZProtection(); 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 FZProtection(); item = (FZProtection)FetchObject(item, p, dbmgr); list.Add(item); } dbmgr.CloseReader(); _firearea.protectionlist = list; }