Modify the Schemaexplorer.mysqlschemaprovider in Codesmith

Source: Internet
Author: User

Modify C:\Program Files (x86) \codesmith\v6.5\samples\projects\csharp\mysqlschemaprovider\mysqlschemaprovider.cs

The modification of the Getcommandparameters method was not implemented originally. Always reported error message: 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>         PublicParameterschema[] Getcommandparameters (stringconnectionString, 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 would 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));             */            stringCommandText =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_positio N", command. Database.name, command.            Name); List<ParameterSchema> Parameterschema =NewList<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 ()) {stringname = Reader. GetString (0 ); stringNativeType = reader. GetString (1 ); LongLongsize = (reader. IsDBNull (2) ==false) ? Reader. GetInt64 (2) :0; bytePrecision = (byte) (reader. IsDBNull (3) ==false) ? Reader. GetInt32 (3) :0 ); intScale = (reader. IsDBNull (4) ==false) ? Reader. GetInt32 (4) :0; BOOLIsNullable = (reader. IsDBNull (5) ==false) && Reader. Getboolean (5 ); stringDirection = reader. GetString (6 ); ParameterDirection paramdirection=ParameterDirection.Input; Switch(direction) { Case "inch": Paramdirection=ParameterDirection.Input;  Break;  Case " out": Paramdirection=ParameterDirection.Output;  Break;  Case "INOUT": Paramdirection=Parameterdirection.inputoutput;  Break; default: Paramdirection=ParameterDirection.Input;  Break; }                        intSize = (Longsize <int. MaxValue)? (int) Longsize:int.                        MaxValue; BOOLisunsigned = (Nativetype.indexof ("unsigned") >-1 ); DbType type=Getdbtype (NativeType, isunsigned); Parameterschema.add (NewParameterschema (command,name,paramdirection,type,nativetype,size,precision,scale,isnullable)); }                    if(!Reader. IsClosed) reader.                Close (); }                if(Connection. State! =connectionstate.closed) connection.            Close (); }            returnParameterschema.toarray (); }

Generates SchemaExplorer.MySQLSchemaProvider.dll after compilation, overwriting files of the same name in the Schemaproviders directory in the program installation directory.

Modified to replace the file with the same name in the directory (C:\Program files (x86) \codesmith\v6.5\schemaproviders\schemaexplorer.mysqlschemaprovider.dll).

After you start Codesmith, you need to delete the original MySQL database in the Schema Explorer and add it again, or you will get an error.

You can also uninstall the SchemaExplorer.MySQLSchemaProvider.dll in the GAC, and then install your own modified, compiled, and signed SchemaExplorer.MySQLSchemaProvider.dll into the GAC.

Modify the Schemaexplorer.mysqlschemaprovider in Codesmith

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.