Example #1
0
        public void LoadTables(SqlConnection conn)
        {
            SqlCommand cmd = new SqlCommand("p_ListTables", conn) { CommandType = CommandType.StoredProcedure };

            Tables = new List<Table>();
            try
            {
                SqlDataReader reader = cmd.ExecuteReader();
                Table table = Table.None;
                while (reader.Read())
                {
                    string tableName = reader["table"].ToString();
                    if (tableName != table.Name && tableName + _settings.CollisionPostfix != table.Name)
                    {
                        if (table != Table.None)
                            Tables.Add(table);

                        table = new Table(tableName);
                    }

                    Column col = new Column(reader["column"].ToString(), reader["type"].ToString(), (bool)reader["nullable"], (bool)reader["identity"]);

                    if (col.Name == table.Name)
                        table.HasCollision = true;

                    table.Columns.Add(col);
                }

                Tables.Add(table); // add the last table from the result set.
            }
            catch (Exception ex)
            {
                Logger.Error("Parse error: ({0}) {1}", ex.GetType().Name, ex.Message);
                throw new ReturnException(ReturnCode.Unknown);
            }

            Logger.Info("Done database stuff");
        }
Example #2
0
 static Table()
 {
     None = new Table("");
 }