Skip to content

Commit

Permalink
Adding MySqlProvider.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wagner Andrade committed Aug 22, 2012
1 parent 74416dd commit 7823bd9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
40 changes: 40 additions & 0 deletions 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);
}
}
}
1 change: 1 addition & 0 deletions Thunderstruck/Runtime/ProviderResolver.cs
Expand Up @@ -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;
}
}
Expand Down
1 change: 1 addition & 0 deletions Thunderstruck/Thunderstruck.csproj
Expand Up @@ -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" />
Expand Down

0 comments on commit 7823bd9

Please sign in to comment.