// METHOD HEADER COMMENT ------------------------------------------------------------------------------- /** * \fn Select * \brief This select statement will take in a table type and a optional Id number for the table * It will return a list of objects that can then be cast to the correct class type * \param[in] ParentTable tabletype, int TableID = -1 * \param[out] None * \return List<object> * ---------------------------------------------------------------------------------------------------- */ public static List <object> Select(ParentTable tabletype, int TableID = -1) { //get the select statement for the table string query = tabletype.GetSelectStatment(); if (TableID != -1) { //if a id was passed in, add a where class to the select statement string sufix = " where " + tabletype.GetTableName() + "ID = " + TableID.ToString() + ";"; query = query.Replace(";", sufix); } //Create as array list to store the result List <string>[] list = new List <string> [tabletype.GetColoumInt()]; for (int i = 0; i < list.Length; i++) { list[i] = new List <string>(); } //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //get the column names from the List <string> ColomNames = tabletype.GetColoumNames(); //Read the data and store them in the array of lists while (dataReader.Read()) { for (int i = 0; i < list.Length; i++) { list[i].Add(dataReader[ColomNames[i]] + ""); } } //close Data Reader dataReader.Close(); //take the array of lists, and convert it to a list of objects List <object> outList = tabletype.PackageClasses(list); TMSLogger.LogIt(" | " + "SQL.cs" + " | " + "SQL" + " | " + "Select" + " | " + "Confirmation" + " | " + "Data selected with SQL" + " | "); //return the list return(outList); }