修改C:\Program Files (x86)\CodeSmith\v6.5\Samples\Projects\CSharp\MySQLSchemaProvider\MySQLSchemaProvider.cs

修改GetCommandParameters方法,原本是没有实现的。一直报错误信息:GetCommandParameters() is not supported in this release.

        /// <summary>
/// Gets the parameters for a given command.
/// </summary>
/// <param name="connectionString">The connection string used to connect to the target database.</param>
/// <param name="command"></param>
/// <returns></returns>
public ParameterSchema[] GetCommandParameters( string connectionString, CommandSchema command )
{
// MySQL does not yet implement INFORMATION_SCHEMA.PARAMETERS
// MySQL Connector/Net 1.0.7 is supposed to support DeriveParameters()
// However, in my testing there appears to be a bug (throws a NULL reference exception)
// This method will be unsupported until a subsequent release of DeriverParameters()
// is working. // throw new NotSupportedException( "GetCommandParameters() is not supported in this release." ); /*
ArrayList a = new ArrayList();
ParameterSchema ps;
DbConnection cnx = null;
DbCommand cmd = null;
try
{
cnx = new DbConnection(connectionString); cmd = new DbCommand(command.Name, cnx);
cmd.CommandType = CommandType.StoredProcedure; cnx.Open();
IDbCommandBuilder.DeriveParameters(cmd);
cnx.Close(); foreach(MySqlParameter param in cmd.Parameters)
{
ps = new ParameterSchema(command, param.ParameterName, param.Direction, param.DbType,
param.MySqlDbType.ToString(), param.Size, param.Precision, param.Scale, param.IsNullable); a.Add(ps);
} }
catch
{
throw;
}
finally
{
if (cnx != null)
cnx.Close();
} return (ParameterSchema[]) a.ToArray(typeof (ParameterSchema));
*/ string commandText = string.Format("SELECT PARAMETER_NAME, DATA_TYPE, CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION,"
+ " NUMERIC_SCALE, 0 IS_NULLABLE, PARAMETER_MODE"
+ " FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_SCHEMA = '{0}' AND SPECIFIC_NAME = '{1}' AND ROUTINE_TYPE = 'PROCEDURE' ORDER BY ORDINAL_POSITION", command.Database.Name, command.Name);
List<ParameterSchema> parameterSchema = new List<ParameterSchema>(); using (DbConnection connection = CreateConnection(connectionString))
{
connection.Open(); DbCommand cmd = connection.CreateCommand();
cmd.CommandText = commandText;
cmd.Connection = connection; using (IDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
while (reader.Read())
{
string name = reader.GetString( );
string nativeType = reader.GetString( );
long longSize = ( reader.IsDBNull( ) == false ) ? reader.GetInt64( ) : ;
byte precision = ( byte ) ( ( reader.IsDBNull( ) == false ) ? reader.GetInt32( ) : );
int scale = ( reader.IsDBNull( ) == false ) ? reader.GetInt32( ) : ;
bool isNullable = ( reader.IsDBNull( ) == false ) && reader.GetBoolean( );
string direction = reader.GetString( );
ParameterDirection paramDirection = ParameterDirection.Input;
switch(direction)
{
case "IN":
paramDirection = ParameterDirection.Input;
break;
case "OUT":
paramDirection = ParameterDirection.Output;
break;
case "INOUT":
paramDirection = ParameterDirection.InputOutput;
break;
default:
paramDirection = ParameterDirection.Input;
break;
}
int size = ( longSize < int.MaxValue ) ? ( int ) longSize : int.MaxValue; bool isUnsigned = ( nativeType.IndexOf( "unsigned" ) > - );
DbType type = GetDbType( nativeType, isUnsigned ); parameterSchema.Add(new ParameterSchema(command,name,paramDirection,type,nativeType,size,precision,scale,isNullable));
} if (!reader.IsClosed)
reader.Close();
} if (connection.State != ConnectionState.Closed)
connection.Close();
} return parameterSchema.ToArray();
}

编译后生成SchemaExplorer.MySQLSchemaProvider.dll,覆盖程序安装目录中SchemaProviders目录的同名文件。

修改后替换目录(C:\Program Files (x86)\CodeSmith\v6.5\SchemaProviders\SchemaExplorer.MySQLSchemaProvider.dll)中的同名文件。

启动CodeSmith后,需要在Schema Explorer中删除原来的MySQL数据库,重新添加,不然会报错。

也可以先卸载GAC中的SchemaExplorer.MySQLSchemaProvider.dll,然后将自己修改、编译并签名后的SchemaExplorer.MySQLSchemaProvider.dll安装到GAC中。

最新文章

  1. [转]Android App整体架构设计的思考
  2. PHP 输出图像 imagegif 、imagejpeg 与 imagepng 函数
  3. 【Git】基本命令使用
  4. 微信第一个“小程序”亮相:不是APP胜似APP!
  5. dao、domain、service、web、vo、Model这些层的功能是什么
  6. Google免费的SVN服务器管理VS2010代码
  7. 【超酷超实用】CSS3可滑动跳转的分页插件制作教程
  8. 【deep learning学习笔记】注释yusugomori的RBM代码 --- 头文件
  9. Android编程中的实用快捷键
  10. 树莓派中QT实现I2C
  11. java编程目录
  12. DPI与DFI技术分析
  13. postman(四):添加变量
  14. DotNetBar 控件设置空内容时显示内容
  15. 查看tomcat运行状态
  16. JUC 之 ThreadPoolExecutor 的一些研究
  17. jzoj4419
  18. 利用Tensorflow读取二进制CIFAR-10数据集
  19. php 中 拓展 xdebug的完全理解
  20. 什么是Cookie。Cookie的原理介绍,Cookie的简单应用

热门文章

  1. onblur事件和click事件冲突
  2. mysqldump备份与基于bin-log实现完全恢复
  3. 快速玩转linux(1)
  4. node 写api几个简单的问题
  5. MySQL实现排名并查询指定用户排名功能,并列排名功能
  6. 深入理解is_callable和method_exists
  7. Python学习之模块基础
  8. 嵌入式框架Zorb Framework搭建七:任务的实现
  9. CentOS(Linux)安装KETTLE教程 并配置执行定时任务
  10. UVA10474 Where is the Marble?【排序】