@@ -202,8 +202,8 @@ private static Result<Expression> CreateComparisonExpression(string operatorKeyw
202202 {
203203 return operatorKeyword switch
204204 {
205- Keywords . Eq => Expression . Equal ( expression , value ) ,
206- Keywords . Ne => Expression . NotEqual ( expression , value ) ,
205+ Keywords . Eq => CreateEqualityExpression ( expression , value , isEqual : true ) ,
206+ Keywords . Ne => CreateEqualityExpression ( expression , value , isEqual : false ) ,
207207 Keywords . Contains => CreateContainsExpression ( expression , value ) ,
208208 Keywords . Lt => Expression . LessThan ( expression , value ) ,
209209 Keywords . Lte => Expression . LessThanOrEqual ( expression , value ) ,
@@ -263,6 +263,24 @@ private static Expression CreateContainsExpression(Expression expression, Consta
263263 return Expression . Call ( expressionToLower , StringContainsMethod , valueToLower ) ;
264264 }
265265
266+ private static Expression CreateEqualityExpression ( Expression expression , ConstantExpression value , bool isEqual )
267+ {
268+ // For string comparisons, make them case-insensitive
269+ if ( expression . Type == typeof ( string ) )
270+ {
271+ var expressionToLower = Expression . Call ( expression , StringToLowerMethod ) ;
272+ var valueToLower = Expression . Call ( value , StringToLowerMethod ) ;
273+ return isEqual
274+ ? Expression . Equal ( expressionToLower , valueToLower )
275+ : Expression . NotEqual ( expressionToLower , valueToLower ) ;
276+ }
277+
278+ // For non-string types, use standard equality
279+ return isEqual
280+ ? Expression . Equal ( expression , value )
281+ : Expression . NotEqual ( expression , value ) ;
282+ }
283+
266284 private static Result < Expression > EvaluateInfixExpression ( InfixExpression exp , FilterEvaluationContext context )
267285 {
268286 if ( exp . Left is PropertyPath propertyPath )
0 commit comments