@@ -4064,6 +4064,9 @@ private SQLiteCommand GenerateCommand (string selectionList)
4064
4064
}
4065
4065
cmdText += " offset " + _offset . Value ;
4066
4066
}
4067
+
4068
+ //Remove all StringComparison arguments from args, otherwise the created command may unmatch with the real arguments.
4069
+ args . RemoveAll ( x => x is StringComparison ) ;
4067
4070
return Connection . CreateCommand ( cmdText , args . ToArray ( ) ) ;
4068
4071
}
4069
4072
}
@@ -4133,7 +4136,24 @@ private CompileResult CompileExpr (Expression expr, List<object> queryArgs)
4133
4136
sqlCall = "(" + args [ 0 ] . CommandText + " like " + args [ 1 ] . CommandText + ")" ;
4134
4137
}
4135
4138
else if ( call . Method . Name == "Contains" && args . Length == 2 ) {
4136
- sqlCall = "(" + args [ 1 ] . CommandText + " in " + args [ 0 ] . CommandText + ")" ;
4139
+ //Add Contains method with StringComparison parameter.
4140
+ if ( call . Object != null && call . Object . Type == typeof ( string ) && args [ 1 ] . Value is StringComparison comparison ) {
4141
+ switch ( comparison ) {
4142
+ case StringComparison . Ordinal :
4143
+ case StringComparison . CurrentCulture :
4144
+ case StringComparison . InvariantCulture :
4145
+ sqlCall = "(instr(" + obj . CommandText + "," + args [ 0 ] . CommandText + ") > 0)" ;
4146
+ break ;
4147
+ case StringComparison . OrdinalIgnoreCase :
4148
+ case StringComparison . CurrentCultureIgnoreCase :
4149
+ case StringComparison . InvariantCultureIgnoreCase :
4150
+ sqlCall = "(" + obj . CommandText + " like ('%' ||" + args [ 0 ] . CommandText + "|| '%'))" ;
4151
+ break ;
4152
+ }
4153
+ }
4154
+ else {
4155
+ sqlCall = "(" + args [ 1 ] . CommandText + " in " + args [ 0 ] . CommandText + ")" ;
4156
+ }
4137
4157
}
4138
4158
else if ( call . Method . Name == "Contains" && args . Length == 1 ) {
4139
4159
if ( call . Object != null && call . Object . Type == typeof ( string ) ) {
0 commit comments