public RouteBDEndpoint(RouteBDEndpoint 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 FetchBDEndpointList(int id, IDBManager dbmgr) { string bd_endpt = Get_BD_ENDPT(id, dbmgr); _route.bd_endpt = bd_endpt.Replace("'", ""); if (_route.bd_endpt=="") _route.bdendpointlist=null; else { string qryString = "SELECT * FROM viewBDENDPOINTS e WHERE e.BD_ENDPT IN (" + bd_endpt + ") ORDER BY e.ENDPT"; RouteBDEndpoint item = new RouteBDEndpoint(); // create new object type to be able to get property info ArrayList list = new ArrayList(); // create new ArrayList to house objects PropertyInfo[] p = item.GetType().GetProperties(); // get property info for item dbmgr.ExecuteReader(CommandType.Text, qryString); // execute query while (dbmgr.DataReader.Read()) { item = new RouteBDEndpoint(); // create new item item = (RouteBDEndpoint)FetchObject(item, p, dbmgr); list.Add(item); // add item to the ArrayList } dbmgr.CloseReader(); _route.bdendpointlist = list; //update item list } }