Skip to content

Commit d9ee187

Browse files
Introduce StringToLowerDefault, a global switch (#321)
1 parent 95c63f8 commit d9ee187

4 files changed

Lines changed: 19 additions & 1 deletion

File tree

net/DevExtreme.AspNet.Data.Tests.Common/StaticBarrier.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public static void Run(Action action) {
1515
} finally {
1616
CustomAggregators.Clear();
1717
CustomAccessorCompilers.Clear();
18+
DataSourceLoadOptionsBase.StringToLowerDefault = null;
1819
}
1920
}
2021

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ public void Dynamic() {
7777
Assert.True((bool)method.DynamicInvoke('c'));
7878
}
7979

80+
[Fact]
81+
public void GlobalSwitch() {
82+
StaticBarrier.Run(delegate {
83+
var options = new SampleLoadOptions {
84+
Filter = new[] { "this", "contains", "A" }
85+
};
86+
DataSourceLoadOptionsBase.StringToLowerDefault = false;
87+
DataSourceLoader.Load(new[] { "" }, options).data.Cast<object>().ToArray();
88+
Assert.DoesNotContain(options.ExpressionLog, line => line.Contains("ToLower"));
89+
});
90+
}
91+
8092
void AssertFilter<T>(bool guardNulls, bool stringToLower, string op, string expectedExpr) {
8193
expectedExpr = expectedExpr.Replace("'", "\"");
8294

net/DevExtreme.AspNet.Data/DataSourceLoadContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ partial class DataSourceLoadContext {
4444
partial class DataSourceLoadContext {
4545
public IList Filter => _options.Filter;
4646
public bool HasFilter => !IsEmptyList(_options.Filter);
47-
public bool UseStringToLower => _options.StringToLower.GetValueOrDefault(_providerInfo.IsLinqToObjects);
47+
public bool UseStringToLower => _options.StringToLower ?? DataSourceLoadOptionsBase.StringToLowerDefault ?? _providerInfo.IsLinqToObjects;
4848
}
4949

5050
// Grouping

net/DevExtreme.AspNet.Data/DataSourceLoadOptionsBase.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ namespace DevExtreme.AspNet.Data {
99
/// A class with properties that specify data processing settings.
1010
/// </summary>
1111
public class DataSourceLoadOptionsBase {
12+
/// <summary>
13+
/// A global default value for the <see cref="StringToLower" /> property
14+
/// </summary>
15+
public static bool? StringToLowerDefault { get; set; }
16+
1217
/// <summary>
1318
/// A flag indicating whether the total number of data objects is required.
1419
/// </summary>

0 commit comments

Comments
 (0)