CodeSmith7串連Mysql

來源:互聯網
上載者:User

標籤:

由於CodeSmith串連MySql的dll有點小Bug,無法擷取表和列的描述資訊,所以,需要重新修改驅動程式。

如所示,CodeSmith的mysql驅動是無法擷取表和列的描述。所以我們需要重新修改MySQLSchemaProvide。步驟如下:

  1. 按照路徑,開啟項目。
  2. 注意需要重新引入dll。
  3. 開啟mysql用戶端程式,先查看錶結構和列結構.
  4. 開啟項目,修改代碼,關鍵代碼如下:
  5. 上面是增加了表的描述列,方法的下面是表的描述,原有內容為:
    if (schemaObject is TableSchema)            {                TableSchema tableSchema = schemaObject as TableSchema;                string commandText = string.Format(@"SHOW CREATE TABLE `{0}`.`{1}`", tableSchema.Database.Name, tableSchema.Name);                using (DbConnection connection = CreateConnection(connectionString))                {                    connection.Open();                    DbCommand command = connection.CreateCommand();                    command.CommandText = commandText;                    command.Connection = connection;                    using (IDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection))                    {                        while (reader.Read())                        {                            string createtable = reader.GetString(1);                            extendedProperties.Add(new ExtendedProperty("CS_CreateTableScript", createtable, DbType.String));                        }                        if (!reader.IsClosed)                            reader.Close();                    }                    if (connection.State != ConnectionState.Closed)                        connection.Close();                }            }
  6. 將上面的sql語句修改為Select TABLE_NAME,TABLE_COMMENT From information_schema.`TABLES` where TABLE_SCHEMA=‘{0}‘ and TABLE_NAME=‘{1}‘。並且將extendedProperties.Add(new ExtendedProperty("CS_CreateTableScript", createtable, DbType.String));修改為 extendedProperties.Add(new ExtendedProperty("CS_Description", createtable, DbType.String));
  7. 重新編譯後,將編譯後的dll組件替換codeSmith7裡面的dll。路徑
  8. 最終

若需要完成的dll,可以留下郵件地址。抽空可以發送完成的dll給大家。

CodeSmith7串連Mysql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.