Skip to content

Commit b7cb96a

Browse files
IBinaryExpressionInfo.StringToLower (#445)
1 parent c88d3dc commit b7cb96a

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

net/DevExtreme.AspNet.Data.Tests/CustomFilterCompilersTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,29 @@ public void ArrayContainsWithNullGuard() {
9191
}
9292
}
9393

94+
[Fact]
95+
public void StringToLower() {
96+
try {
97+
var stringToLowerLog = new List<bool>();
98+
99+
CustomFilterCompilers.RegisterBinaryExpressionCompiler(info => {
100+
stringToLowerLog.Add(info.StringToLower);
101+
return Expression.Constant(true);
102+
});
103+
104+
foreach(var stringToLower in new[] { false, true }) {
105+
DataSourceLoader.Load(new Product[0], new SampleLoadOptions {
106+
Filter = new[] { "any", "any", "any" },
107+
StringToLower = stringToLower
108+
});
109+
}
110+
111+
Assert.False(stringToLowerLog[0]);
112+
Assert.True(stringToLowerLog[1]);
113+
} finally {
114+
CustomFilterCompilers.Binary.CompilerFuncs.Clear();
115+
}
116+
}
94117

95118
class Product {
96119
public string Name { get; set; }

net/DevExtreme.AspNet.Data/FilterExpressionCompiler.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ Expression CompileBinary(ParameterExpression dataItemExpr, IList criteriaJson) {
5353
DataItemExpression = dataItemExpr,
5454
AccessorText = clientAccessor,
5555
Operation = clientOperation,
56-
Value = clientValue
56+
Value = clientValue,
57+
StringToLower = _stringToLower
5758
});
5859

5960
if(customResult != null)
@@ -290,6 +291,7 @@ class BinaryExpressionInfo : IBinaryExpressionInfo {
290291
public string AccessorText { get; set; }
291292
public string Operation { get; set; }
292293
public object Value { get; set; }
294+
public bool StringToLower { get; set; }
293295
}
294296
}
295297

net/DevExtreme.AspNet.Data/Helpers/IBinaryExpressionInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public interface IBinaryExpressionInfo {
88
string AccessorText { get; }
99
string Operation { get; }
1010
object Value { get; }
11+
bool StringToLower { get; }
1112
}
1213

1314
}

0 commit comments

Comments
 (0)