Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding MySqlProvider.

  • Loading branch information...
commit 7823bd9b55b816d2c28af6ee6d18e93d5dfb1584 1 parent 74416dd
@wagnerandrade authored
View
40 Thunderstruck/Provider/Common/MySqlProvider.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Thunderstruck.Provider;
+
+namespace Thunderstruck.Provider.Common
+{
+ public class MySqlProvider : DefaultProvider
+ {
+ public override int ExecuteGetIdentity(string command, object commandParams)
+ {
+ var identityQuery = String.Concat(command, "; SELECT last_insert_id();");
+ var value = CreateDbCommand(identityQuery, commandParams).ExecuteScalar();
+ return Convert.ToInt32(value);
+
+ throw new NotImplementedException();
+ }
+
+ public override string FieldFormat
+ {
+ get { return "`{0}`"; }
+ }
+
+ public override string ParameterIdentifier
+ {
+ get { return "@"; }
+ }
+
+ public override string SelectAllQuery(string projection, string where)
+ {
+ return String.Format("SELECT {0} {1}", projection, where);
+ }
+
+ public override string SelectTakeQuery(string projection, string where, int count)
+ {
+ return String.Format("SELECT {0} {1} LIMIT {2}", projection, where, count);
+ }
+ }
+}
View
1  Thunderstruck/Runtime/ProviderResolver.cs
@@ -19,6 +19,7 @@ public IDataProvider Create(string providerName)
{
case "System.Data.SqlClient": return new SqlProvider();
case "System.Data.OracleClient": return new OracleProvider();
+ case "MySql.Data.MySqlClient": return new MySqlProvider();
default: return null;
}
}
View
1  Thunderstruck/Thunderstruck.csproj
@@ -46,6 +46,7 @@
<Compile Include="IgnoreAttribute.cs" />
<Compile Include="DataObjectCommand.cs" />
<Compile Include="DataObjectQuery.cs" />
+ <Compile Include="Provider\Common\MySqlProvider.cs" />
<Compile Include="Provider\Common\OracleProvider.cs" />
<Compile Include="Provider\Common\SqlProvider.cs" />
<Compile Include="Provider\IDataProvider.cs" />
Please sign in to comment.
Something went wrong with that request. Please try again.