22using System . Collections . Generic ;
33using System . Data ;
44using System . Data . Common ;
5- using System . Reflection ;
65using System . Text ;
76using NHibernate . AdoNet . Util ;
87using NHibernate . Exceptions ;
@@ -16,7 +15,7 @@ namespace NHibernate.AdoNet
1615 public class OracleDataClientBatchingBatcher : AbstractBatcher
1716 {
1817 private int _batchSize ;
19- private int _countOfCommands = 0 ;
18+ private int _countOfCommands ;
2019 private int _totalExpectedRowsAffected ;
2120 private IDbCommand _currentBatch ;
2221 private IDictionary < string , List < object > > _parameterValueListHashTable ;
@@ -69,9 +68,9 @@ public override void AddToBatch(IExpectation expectation)
6968 firstOnBatch = false ;
7069 }
7170
72- List < object > parameterValueList ;
7371 foreach ( IDataParameter currentParameter in CurrentCommand . Parameters )
7472 {
73+ List < object > parameterValueList ;
7574 if ( firstOnBatch )
7675 {
7776 parameterValueList = new List < object > ( ) ;
@@ -125,7 +124,7 @@ protected override void DoExecuteBatch(IDbCommand ps)
125124 // setting the ArrayBindCount on the OracleCommand
126125 // this value is not a part of the ADO.NET API.
127126 // It's and ODP implementation, so it is being set by reflection
128- SetObjectParam ( _currentBatch , "ArrayBindCount" , arraySize ) ;
127+ SetArrayBindCount ( arraySize ) ;
129128 int rowsAffected ;
130129 try
131130 {
@@ -149,11 +148,12 @@ protected override int CountOfStatementsInCurrentBatch
149148 get { return _countOfCommands ; }
150149 }
151150
152- private void SetObjectParam ( Object obj , string paramName , object paramValue )
151+ private void SetArrayBindCount ( int arraySize )
153152 {
154- System . Type objType = obj . GetType ( ) ;
155- PropertyInfo propInfo = objType . GetProperty ( paramName ) ;
156- propInfo . SetValue ( obj , paramValue , null ) ;
153+ //TODO: cache the property info.
154+ var objType = _currentBatch . GetType ( ) ;
155+ var propInfo = objType . GetProperty ( "ArrayBindCount" ) ;
156+ propInfo . SetValue ( _currentBatch , arraySize , null ) ;
157157 }
158158
159159 public override int BatchSize
0 commit comments