@@ -105,11 +105,6 @@ public QueryParameters(IType[] positionalParameterTypes, object[] positionalPara
105
105
_collectionKeys = collectionKeys ;
106
106
_readOnly = readOnly ;
107
107
_resultTransformer = transformer ;
108
-
109
- if ( _positionalParameterLocations == null )
110
- {
111
- CreatePositionalParameterLocations ( ) ;
112
- }
113
108
}
114
109
115
110
public QueryParameters ( IType [ ] positionalParameterTypes , object [ ] positionalParameterValues ,
@@ -196,15 +191,15 @@ public IDictionary<string, LockMode> LockModes
196
191
set { _lockModes = value ; }
197
192
}
198
193
199
- private void CreatePositionalParameterLocations ( )
194
+ private void CreatePositionalParameterLocations ( ISessionFactoryImplementor factory )
200
195
{
201
- if ( _positionalParameterTypes != null )
196
+ _positionalParameterLocations = new int [ _positionalParameterTypes . Length ] ;
197
+ int location = 0 ;
198
+ for ( int i = 0 ; i < _positionalParameterLocations . Length ; i ++ )
202
199
{
203
- _positionalParameterLocations = new int [ _positionalParameterTypes . Length ] ;
204
- for ( int i = 0 ; i < _positionalParameterLocations . Length ; i ++ )
205
- {
206
- _positionalParameterLocations [ i ] = i ;
207
- }
200
+ var span = _positionalParameterTypes [ i ] . GetColumnSpan ( factory ) ;
201
+ _positionalParameterLocations [ i ] = location ;
202
+ location += span ;
208
203
}
209
204
}
210
205
@@ -460,6 +455,8 @@ public SqlType[] PrepareParameterTypes(SqlString sqlString, ISessionFactoryImple
460
455
int parameterIndex = 0 ;
461
456
int totalSpan = 0 ;
462
457
458
+ CreatePositionalParameterLocations ( factory ) ;
459
+
463
460
IList < Parameter > sqlParameters = FindParametersIn ( sqlString ) ;
464
461
465
462
for ( int index = 0 ; index < PositionalParameterTypes . Length ; index ++ )
@@ -470,7 +467,7 @@ public SqlType[] PrepareParameterTypes(SqlString sqlString, ISessionFactoryImple
470
467
int location = PositionalParameterLocations [ index ] ;
471
468
location = FindAdjustedParameterLocation ( location ) ;
472
469
int span = type . GetColumnSpan ( factory ) ;
473
- SetParameterLocation ( sqlParameters , startParameterIndex + parameterIndex , location , span ) ;
470
+ SetParameterLocation ( sqlParameters , startParameterIndex + totalSpan , location , span ) ;
474
471
475
472
totalSpan += span ;
476
473
parameterIndex ++ ;
@@ -483,7 +480,7 @@ public SqlType[] PrepareParameterTypes(SqlString sqlString, ISessionFactoryImple
483
480
484
481
int location = FilteredParameterLocations [ index ] ;
485
482
int span = type . GetColumnSpan ( factory ) ;
486
- SetParameterLocation ( sqlParameters , startParameterIndex + parameterIndex , location , span ) ;
483
+ SetParameterLocation ( sqlParameters , startParameterIndex + totalSpan , location , span ) ;
487
484
488
485
totalSpan += span ;
489
486
parameterIndex ++ ;
@@ -510,7 +507,7 @@ public SqlType[] PrepareParameterTypes(SqlString sqlString, ISessionFactoryImple
510
507
while ( ( location < sqlParameters . Count ) && ( sqlParameters [ location ] . ParameterPosition != null ) )
511
508
location ++ ;
512
509
513
- SetParameterLocation ( sqlParameters , startParameterIndex + parameterIndex , location , span ) ;
510
+ SetParameterLocation ( sqlParameters , startParameterIndex + totalSpan , location , span ) ;
514
511
}
515
512
516
513
totalSpan += span ;
0 commit comments