11using System ;
22using System . Data . Common ;
33using System . Diagnostics ;
4- using System . Reflection ;
4+ using MySql . Data . MySqlClient ;
55using NHibernate . Util ;
66
77namespace 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 ( )
0 commit comments