Skip to content

Commit 84f9e60

Browse files
committed
NH-4008 - Move MySql batching classes to driver specific project.
1 parent 4abb75f commit 84f9e60

File tree

5 files changed

+13
-17
lines changed

5 files changed

+13
-17
lines changed

src/NHibernate/AdoNet/MySqlClientSqlCommandSet.cs renamed to src/NHibernate.Driver.MySql/AdoNet/MySqlClientSqlCommandSet.cs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,37 @@
11
using System;
22
using System.Data.Common;
33
using System.Diagnostics;
4-
using System.Reflection;
4+
using MySql.Data.MySqlClient;
55
using NHibernate.Util;
66

77
namespace NHibernate.AdoNet
88
{
99
public class MySqlClientSqlCommandSet : IDisposable
1010
{
1111
private static readonly System.Type adapterType;
12-
private static readonly Action<object> doInitialise;
13-
private static readonly Action<object, int> batchSizeSetter;
14-
private static readonly Action<object, DbCommand> doAppend;
15-
private static readonly Func<object, int> doExecuteNonQuery;
16-
private static readonly Action<object> doDispose;
12+
private static readonly Action<MySqlDataAdapter> doInitialise;
13+
private static readonly Action<MySqlDataAdapter, DbCommand> doAppend;
14+
private static readonly Func<MySqlDataAdapter, int> doExecuteNonQuery;
1715

18-
private readonly object instance;
16+
private readonly MySqlDataAdapter instance;
1917
private int countOfCommands;
2018

2119
static MySqlClientSqlCommandSet()
2220
{
23-
var sysData = Assembly.Load("MySql.Data");
24-
adapterType = sysData.GetType("MySql.Data.MySqlClient.MySqlDataAdapter");
21+
adapterType = typeof(MySqlDataAdapter);
2522
Debug.Assert(adapterType != null, "Could not find MySqlDataAdapter!");
2623

2724
doInitialise = DelegateHelper.BuildAction(adapterType, "InitializeBatching");
28-
batchSizeSetter = DelegateHelper.BuildPropertySetter<int>(adapterType, "UpdateBatchSize");
2925
doAppend = DelegateHelper.BuildAction<DbCommand>(adapterType, "AddToBatch");
3026
doExecuteNonQuery = DelegateHelper.BuildFunc<int>(adapterType, "ExecuteBatch");
31-
doDispose = DelegateHelper.BuildAction(adapterType, "Dispose");
3227
}
3328

3429
public MySqlClientSqlCommandSet(int batchSize)
3530
{
36-
instance = Activator.CreateInstance(adapterType, true);
31+
instance = new MySqlDataAdapter();
32+
instance = (MySqlDataAdapter) Activator.CreateInstance(adapterType, true);
3733
doInitialise(instance);
38-
batchSizeSetter(instance, batchSize);
34+
instance.UpdateBatchSize = batchSize;
3935
}
4036

4137
public void Append(DbCommand command)
@@ -46,7 +42,7 @@ public void Append(DbCommand command)
4642

4743
public void Dispose()
4844
{
49-
doDispose(instance);
45+
instance.Dispose();
5046
}
5147

5248
public int ExecuteNonQuery()

src/NHibernate.Driver.MySql/NHibernate.Driver.MySql.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
<Compile Include="..\SharedAssemblyInfo.cs">
5151
<Link>Properties\SharedAssemblyInfo.cs</Link>
5252
</Compile>
53+
<Compile Include="AdoNet\MySqlClientBatchingBatcher.cs" />
54+
<Compile Include="AdoNet\MySqlClientBatchingBatcherFactory.cs" />
55+
<Compile Include="AdoNet\MySqlClientSqlCommandSet.cs" />
5356
<Compile Include="Cfg\Loquacious\ConnectionConfigurationExtensionMySql.cs" />
5457
<Compile Include="Driver\MySqlDataDriver.cs" />
5558
<Compile Include="Properties\AssemblyInfo.cs" />

src/NHibernate/NHibernate.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@
9696
<Link>SharedAssemblyInfo.cs</Link>
9797
</Compile>
9898
<Compile Include="ADOException.cs" />
99-
<Compile Include="AdoNet\MySqlClientBatchingBatcher.cs" />
100-
<Compile Include="AdoNet\MySqlClientBatchingBatcherFactory.cs" />
101-
<Compile Include="AdoNet\MySqlClientSqlCommandSet.cs" />
10299
<Compile Include="AssemblyInfo.cs" />
103100
<Compile Include="AssertionFailure.cs" />
104101
<Compile Include="Bytecode\DefaultProxyFactoryFactory.cs" />

0 commit comments

Comments
 (0)