Skip to content

Commit f5d0682

Browse files
committed
fix(filter): Fixed linq2sql for string contains comparison ignore case
1 parent 4423492 commit f5d0682

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/GoatQuery/src/Evaluator/FilterEvaluator.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,14 @@ public static Result<Expression> Evaluate(QueryExpression expression, ParameterE
7171
case Keywords.Contains:
7272
var identifier = (Identifier)exp.Left;
7373

74-
var method = identifier.Value.GetType().GetMethod("Contains", new[] { value?.Value.GetType(), typeof(StringComparison) });
74+
var toLowerMethod = identifier.Value.GetType().GetMethod("ToLower", Type.EmptyTypes);
7575

76-
return Expression.Call(property, method, value, Expression.Constant(StringComparison.OrdinalIgnoreCase));
76+
var propertyToLower = Expression.Call(property, toLowerMethod);
77+
var valueToLower = Expression.Call(value, toLowerMethod);
78+
79+
var containsMethod = identifier.Value.GetType().GetMethod("Contains", new[] { value?.Value.GetType() });
80+
81+
return Expression.Call(propertyToLower, containsMethod, valueToLower);
7782
case Keywords.Lt:
7883
return Expression.LessThan(property, value);
7984
case Keywords.Lte:

0 commit comments

Comments
 (0)