@@ -13,6 +13,7 @@ class CommandBuilder : ICommandBuilder
1313 {
1414 private int _number ;
1515 private Func < IDbCommand , IDbParameterFactory > _getParameterFactory ;
16+ private readonly DatabaseSchema _schema ;
1617 private readonly ISchemaProvider _schemaProvider ;
1718 private readonly Dictionary < ParameterTemplate , object > _parameters = new Dictionary < ParameterTemplate , object > ( ) ;
1819 private readonly StringBuilder _text ;
@@ -28,6 +29,7 @@ public CommandBuilder(DatabaseSchema schema) : this(schema, -1)
2829 public CommandBuilder ( DatabaseSchema schema , int bulkIndex )
2930 {
3031 _text = new StringBuilder ( ) ;
32+ _schema = schema ;
3133 _schemaProvider = schema . SchemaProvider ;
3234 _customInterfaceProvider = schema . ProviderHelper ;
3335 _parameterSuffix = ( bulkIndex >= 0 ) ? "_c" + bulkIndex : string . Empty ;
@@ -36,6 +38,7 @@ public CommandBuilder(DatabaseSchema schema, int bulkIndex)
3638 public CommandBuilder ( string text , DatabaseSchema schema , int bulkIndex )
3739 {
3840 _text = new StringBuilder ( text ) ;
41+ _schema = schema ;
3942 _schemaProvider = schema . SchemaProvider ;
4043 _customInterfaceProvider = schema . ProviderHelper ;
4144 _parameterSuffix = ( bulkIndex >= 0 ) ? "_c" + bulkIndex : string . Empty ;
@@ -166,7 +169,7 @@ private void SetParameters(IDbCommand command, IEnumerable<KeyValuePair<Paramete
166169 SetParameters ( parameterFactory , command , parameters ) ;
167170 }
168171
169- private static void SetParameters ( IDbParameterFactory parameterFactory , IDbCommand command , IEnumerable < KeyValuePair < ParameterTemplate , object > > parameters )
172+ private void SetParameters ( IDbParameterFactory parameterFactory , IDbCommand command , IEnumerable < KeyValuePair < ParameterTemplate , object > > parameters )
170173 {
171174 var parameterList = parameters . ToList ( ) ;
172175 if ( parameterList . Any ( kvp => kvp . Value is IRange ) ||
@@ -189,7 +192,7 @@ private static void SetParameters(IDbParameterFactory parameterFactory, IDbComma
189192 }
190193 }
191194
192- private static IEnumerable < IDbDataParameter > CreateParameterComplex ( IDbParameterFactory parameterFactory , ParameterTemplate template , object value , IDbCommand command )
195+ private IEnumerable < IDbDataParameter > CreateParameterComplex ( IDbParameterFactory parameterFactory , ParameterTemplate template , object value , IDbCommand command )
193196 {
194197 if ( template . Column != null && template . Column . IsBinary )
195198 {
@@ -228,13 +231,13 @@ private static IEnumerable<IDbDataParameter> CreateParameterComplex(IDbParameter
228231 if ( command . CommandText . Contains ( "!= " + template . Name ) )
229232 {
230233 command . CommandText = command . CommandText . Replace ( "!= " + template . Name ,
231- "NOT IN (" +
234+ _schema . Operators . NotIn + " (" +
232235 builder . ToString ( ) . Substring ( 1 ) + ")" ) ;
233236 }
234237 else
235238 {
236239 command . CommandText = command . CommandText . Replace ( "= " + template . Name ,
237- "IN (" +
240+ _schema . Operators . In + " (" +
238241 builder . ToString ( ) . Substring ( 1 ) +
239242 ")" ) ;
240243 }
@@ -248,17 +251,17 @@ private static IEnumerable<IDbDataParameter> CreateParameterComplex(IDbParameter
248251 }
249252 }
250253
251- public static void SetBetweenInCommandText ( IDbCommand command , string name )
254+ public void SetBetweenInCommandText ( IDbCommand command , string name )
252255 {
253256 if ( command . CommandText . Contains ( "!= " + name ) )
254257 {
255258 command . CommandText = command . CommandText . Replace ( "!= " + name ,
256- string . Format ( "NOT BETWEEN {0}_start AND {0 }_end" , name ) ) ;
259+ string . Format ( "{0} {1} _start AND {1 }_end" , _schema . Operators . NotBetween , name ) ) ;
257260 }
258261 else
259262 {
260263 command . CommandText = command . CommandText . Replace ( "= " + name ,
261- string . Format ( "BETWEEN {0}_start AND {0 }_end" , name ) ) ;
264+ string . Format ( "{0} {1} _start AND {1 }_end" , _schema . Operators . Between , name ) ) ;
262265 }
263266 }
264267
@@ -289,7 +292,7 @@ private static IDbDataParameter CreateSingleParameter(IDbParameterFactory parame
289292 return parameter ;
290293 }
291294
292- internal static IDbCommand CreateCommand ( IDbParameterFactory parameterFactory , ICommandBuilder [ ] commandBuilders , IDbConnection connection )
295+ internal IDbCommand CreateCommand ( IDbParameterFactory parameterFactory , ICommandBuilder [ ] commandBuilders , IDbConnection connection )
293296 {
294297 var command = connection . CreateCommand ( ) ;
295298 parameterFactory = parameterFactory ?? new GenericDbParameterFactory ( command ) ;
0 commit comments