@@ -26,6 +26,11 @@ public class DBContext
2626 /// </summary>
2727 internal static string SqlServerConnectionString ;
2828
29+ /// <summary>
30+ /// Holds 'MySQL' connection string value for the DBContext created.
31+ /// </summary>
32+ internal static string MySqlConnectionString ;
33+
2934 /// <summary>
3035 /// Defines database type and connection string to connect to.
3136 /// </summary>
@@ -38,6 +43,8 @@ public DBContext(DB database, string connectionString)
3843 OracleConnectionString = connectionString ;
3944 else if ( Database . Equals ( DB . SqlServer ) )
4045 SqlServerConnectionString = connectionString ;
46+ else if ( Database . Equals ( DB . MySql ) )
47+ MySqlConnectionString = connectionString ;
4148 }
4249
4350 /// <summary>
@@ -91,6 +98,26 @@ public List<DataDictionary> RetrieveData(string selectSql, bool upperCaseKeys =
9198 }
9299 }
93100 }
101+ else if ( Database . Equals ( DB . MySql ) )
102+ {
103+ using ( var mySqlDBConnection = GetMySqlConnection ( ) )
104+ {
105+ var _systemAdapter = new MySqlAdapter ( ) ;
106+ var reader = _systemAdapter . GetSqlReader ( selectSql , mySqlDBConnection . MySqlConnection ) ;
107+ while ( reader . Read ( ) )
108+ {
109+ var addedRow = new DataDictionary ( ) ;
110+ for ( int i = 0 ; i < reader . FieldCount ; i ++ )
111+ {
112+ if ( upperCaseKeys )
113+ addedRow . Data . Add ( reader . GetName ( i ) . ToUpper ( ) , reader . GetValue ( i ) . ToString ( ) ) ;
114+ else
115+ addedRow . Data . Add ( reader . GetName ( i ) , reader . GetValue ( i ) . ToString ( ) ) ;
116+ }
117+ dataList . Add ( addedRow ) ;
118+ }
119+ }
120+ }
94121 return dataList ;
95122 }
96123
@@ -107,12 +134,22 @@ private OracleDBConnection GetOracleConnection()
107134 /// <summary>
108135 /// Gets 'Sql Server' connection.
109136 /// </summary>
110- /// <returns>'Sql Server' Connection</returns>
137+ /// <returns>'Sql Server' Connection. </returns>
111138 private SqlDBConnection GetSqlServerConnection ( )
112139 {
113140 var _connectionBuilder = new ConnectionBuilder ( ) ;
114141 return _connectionBuilder . GetSqlServerConnection ;
115142 }
143+
144+ /// <summary>
145+ /// Gets 'MySQL' connection.
146+ /// </summary>
147+ /// <returns>'MySQL' Connection.</returns>
148+ private MySqlDBConnection GetMySqlConnection ( )
149+ {
150+ var _connectionBuilder = new ConnectionBuilder ( ) ;
151+ return _connectionBuilder . GetMySqlConnection ;
152+ }
116153 }
117154
118155 /// <summary>
@@ -121,6 +158,7 @@ private SqlDBConnection GetSqlServerConnection()
121158 public enum DB
122159 {
123160 Oracle ,
124- SqlServer
161+ SqlServer ,
162+ MySql
125163 }
126164}
0 commit comments