protected TableModifier(ISQLDriver sQLDriver, Dictionary <string, TableSchema.Column> Columns, string TableName, string PrimaryKeyName) { this._tableName = TableName; this._primaryKeyName = PrimaryKeyName; this._sqlDriver = sQLDriver; this.columns = Columns; }
public UpdateAction(ISQLDriver sQLDriver, Dictionary <string, TableSchema.Column> Columns, string TableName, string PrimaryKeyName) : base(sQLDriver, Columns, TableName, PrimaryKeyName) { }
public MySQLMapper(ISQLDriver driver) { base.driver = driver; }
public void Attach(ISQLDriver driver) { this.driver = driver; }
public PostgresMapper(ISQLDriver driver) { base.driver = driver; }
public static bool Generate(string dbType, string connectionString, string folderPath) { ISQLDriver driver = SQLDriverFactory.GetInstance().GetDriver(dbType); if (driver == null) { return(false); } if (!driver.Open(connectionString)) { return(false); } DatabaseMapper databaseMapper = DatabaseMapperFactory.GetInstance().GetDatabaseMapper(dbType); if (databaseMapper == null) { return(false); } databaseMapper.Attach(driver); List <string> tables = databaseMapper.GetTables(); foreach (string table in tables) { Console.WriteLine("Table name: " + table); Console.WriteLine("\tTable schema:"); Dictionary <string, string> tableSchema = databaseMapper.GetTableSchema(table); foreach (KeyValuePair <string, string> tmp in tableSchema) { Console.WriteLine("\t\t" + tmp.Key + ": " + tmp.Value); } List <string> primaryKeys = databaseMapper.GetTablePrimaryKey(table); if (primaryKeys != null && primaryKeys.Count > 0) { Console.Write("\t\tPrimary key: "); foreach (string primaryKey in primaryKeys) { Console.Write(primaryKey + "\t"); } Console.WriteLine(); } Dictionary <string, string> foreignKeys = databaseMapper.GetTableForeignKeys(table); if (foreignKeys != null && foreignKeys.Count > 0) { Console.Write("\t\tForeign key: "); foreach (KeyValuePair <string, string> foreignKey in foreignKeys) { Console.Write("[" + foreignKey.Key + ", " + foreignKey.Value + "]\t"); } Console.WriteLine(); } List <string> tablesHaveForeignKey = databaseMapper.GetTableHaveForeignKey(table); if (tablesHaveForeignKey != null && tablesHaveForeignKey.Count > 0) { Console.Write("\t\tTable have Foreign key: "); foreach (string tableHaveForeignKey in tablesHaveForeignKey) { Console.Write(tableHaveForeignKey + "\t"); } Console.WriteLine(); } ClassGenerator.Generate(table, tableSchema, primaryKeys, foreignKeys, tablesHaveForeignKey, folderPath); } driver.Close(); return(true); }