Index: MySql.Data/Provider/Source/CommandBuilder.cs =================================================================== --- MySql.Data/Provider/Source/CommandBuilder.cs (revision 1597) +++ MySql.Data/Provider/Source/CommandBuilder.cs (working copy) @@ -40,6 +40,7 @@ { private string finalSelect; private bool returnGeneratedIds; + private static readonly char[] EnumValueSeparater = { ',' }; #region Constructors @@ -129,7 +130,38 @@ p.Precision = Convert.ToByte(row["NUMERIC_PRECISION"]); if (!row["NUMERIC_SCALE"].Equals(DBNull.Value)) p.Scale = Convert.ToByte(row["NUMERIC_SCALE"]); - command.Parameters.Add(p); + if (p.MySqlDbType == MySqlDbType.Enum ) + { + p.MySQLEnumValues.Clear( ) ; + string dtdIdentifier = row[ "DTD_IDENTIFIER" ].ToString( ) ; + string dtdIdentifierKey = "'" ; + + if ( dtdIdentifier.StartsWith( "ENUM", StringComparison.InvariantCultureIgnoreCase ) == true ) + { + dtdIdentifier = dtdIdentifier.Substring( 4 ).Trim( ) ; + } + if ( dtdIdentifier.StartsWith( "(" ) == true && dtdIdentifier.EndsWith( ")" ) == true) + { + dtdIdentifier = dtdIdentifier.Substring( 1, dtdIdentifier.Length - 2 ).Trim( ); + } + dtdIdentifierKey = dtdIdentifier.Substring( 0 , 1 ) ; + switch(dtdIdentifierKey) + { + case "'": + case "\"": + string[] enumValues = dtdIdentifier.Split( EnumValueSeparater , StringSplitOptions.RemoveEmptyEntries ); + string enumValue ; + // Apparently using a foreach loop requires building an enumerator which is excess cycles not required and the follow for loop is more effecient + for ( int iEnumValuesLoopCount = 0 ; iEnumValuesLoopCount < enumValues.Length ; iEnumValuesLoopCount++ ) + { + enumValue = enumValues[ iEnumValuesLoopCount ]; + enumValue = enumValue.Substring( dtdIdentifierKey.Length , enumValue.Length - ( dtdIdentifierKey.Length * 2 ) ) ; + p.MySQLEnumValues.Add( enumValue ); + } + break; + } + } + command.Parameters.Add(p); } } Index: MySql.Data/Provider/Source/parameter.cs =================================================================== --- MySql.Data/Provider/Source/parameter.cs (revision 1597) +++ MySql.Data/Provider/Source/parameter.cs (working copy) @@ -19,6 +19,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; +using System.Collections.Generic; using System.Data; using System.Data.Common; using MySql.Data.Types; @@ -51,6 +52,7 @@ private byte precision; private byte scale; private MySqlDbType mySqlDbType; + private IList< string > mySQLEnumValues = new List< string >( ) ; private DbType dbType; private bool inferType; private bool sourceColumnNullMapping; @@ -231,6 +233,14 @@ } } + public IList MySQLEnumValues + { + get + { + return mySQLEnumValues ; + } + } + /// /// Gets or sets the name of the MySqlParameter. ///