- 论坛徽章:
- 0
|
这两天在研究用Codesmith来自动生成代码提升研发效率。捣腾了半天好不容易让codesmith连接上了mysql,但是在运行模板的时候始终找不到表,从而无法生成模板。
哪个有经验的兄弟帮忙看看。
- public ColumnSchema[] GetColumnSchema(String tableName,String connectString)
- {
- MySQLSchemaProvider provider = new MySQLSchemaProvider();
- DatabaseSchema database = new DatabaseSchema(provider,connectString);
- TableSchema []table = provider.GetTables(connectString, database);
- tableName = tableName.ToUpper();
- TableSchema curTable = null;
- int i = 0;
- for(i = 0;i < table.Length;i++)
- {
- curTable = table[i];
- if (curTable.Name == tableName)
- {
- break;
- }
- }
- //没找到
- if (i >= table.Length)
- {
- return null;
- }
- ColumnSchema[] cols = null;
- if (curTable != null)
- {
- cols = provider.GetTableColumns(connectString,curTable);
- }
- return cols;
- }
复制代码 这个是模板里面获取表的方法,但是始终执行时报找不到表。 |
|