Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/BootstrapBlazor/Extensions/LambdaExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,8 @@ private static Expression GetExpression(this FilterKeyValueAction filter, Expres

private static BinaryExpression Contains(this Expression left, Expression right)
{
var method = typeof(string).GetMethod("Contains", [typeof(string), typeof(StringComparison)])!;
var comparison = Expression.Constant(StringComparison.OrdinalIgnoreCase);
return Expression.AndAlso(Expression.NotEqual(left, Expression.Constant(null)), Expression.Call(left, method, right, comparison));
var method = typeof(string).GetMethod("Contains", [typeof(string)])!;
return Expression.AndAlso(Expression.NotEqual(left, Expression.Constant(null)), Expression.Call(left, method, right));
}

#region Count
Expand Down
8 changes: 4 additions & 4 deletions test/UnitTest/Extensions/LambadaExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ public void GetExpression_Contains()
var filter = new FilterKeyValueAction() { FieldKey = "Name", FieldValue = "test", FilterAction = FilterAction.Contains };
var invoker = filter.GetFilterLambda<Foo>().Compile();
Assert.True(invoker.Invoke(new Foo() { Name = "1test1" }));
Assert.True(invoker.Invoke(new Foo() { Name = "1Test1" }));
Assert.True(invoker.Invoke(new Foo() { Name = "1Test123" }));
Assert.True(invoker.Invoke(new Foo() { Name = "Test" }));
Assert.True(invoker.Invoke(new Foo() { Name = "Test2" }));
Assert.False(invoker.Invoke(new Foo() { Name = "1Test1" }));
Assert.False(invoker.Invoke(new Foo() { Name = "1Test123" }));
Assert.False(invoker.Invoke(new Foo() { Name = "Test" }));
Assert.False(invoker.Invoke(new Foo() { Name = "Test2" }));
}

[Fact]
Expand Down
Loading