コード例 #1
0
        public Database LoadDatabase(List<SchemaData> databaseObjectsToFetch, List<string> allowedSchemas)
        {
            try
            {
                connector.Open();
            }
            catch (Exception e)
            {
                throw new DatabaseLoaderException("Error opening database connection. See inner exception.", e);
            }
            try
            {
                var db = new Database(connector.DatabaseName, DatabaseTypes.MySQL) { Loader = this };
                db.ConnectionInformation = DatabaseConnector.ConnectionInformation;
                SetSchemaFilter(databaseObjectsToFetch);

                foreach (var table in GetTables(databaseObjectsToFetch))
                    db.AddTable(table);

                foreach (var view in GetViews(databaseObjectsToFetch))
                    db.AddView(view);

                GetForeignKeys(db);
                return db;
            }
            catch (Exception e)
            {
                throw new DatabaseLoaderException("Error opening database connection. See inner exception.", e);
            }
            finally
            {
                connector.Close();
            }
        }