diff --git a/PoweredSoft.DynamicLinq.Test/ShortcutTests.cs b/PoweredSoft.DynamicLinq.Test/ShortcutTests.cs index 6df24b4..b0312a8 100644 --- a/PoweredSoft.DynamicLinq.Test/ShortcutTests.cs +++ b/PoweredSoft.DynamicLinq.Test/ShortcutTests.cs @@ -180,7 +180,7 @@ namespace PoweredSoft.DynamicLinq.Test } [TestMethod] - public void NotContains() + public void NotContains2() { var q1 = Persons.AsQueryable().Query(t => t.NotContains("LastName", "ee")); var q1b = Persons.AsQueryable().Where(t => !t.LastName.Contains("ee")); diff --git a/PoweredSoft.DynamicLinq.Test/StringComparision.cs b/PoweredSoft.DynamicLinq.Test/StringComparision.cs index 431d054..aeaf524 100644 --- a/PoweredSoft.DynamicLinq.Test/StringComparision.cs +++ b/PoweredSoft.DynamicLinq.Test/StringComparision.cs @@ -76,6 +76,22 @@ namespace PoweredSoft.DynamicLinq.Test QueryableAssert.AreEqual(a, b, "CaseInsensitive"); } + [TestMethod] + public void NegateNotContains() + { + IQueryable a, b; + + // case sensitive. + a = Persons.AsQueryable().Query(t => t.NotContains("FirstName", "vi", stringComparision: null, negate: true)); + b = Persons.AsQueryable().Where(t => !!t.FirstName.Contains("vi")); + QueryableAssert.AreEqual(a, b, "CaseSensitive"); + + // not case sensitive + a = Persons.AsQueryable().Query(t => t.NotContains("FirstName", "VI", stringComparision: StringComparison.OrdinalIgnoreCase, negate: true)); + b = Persons.AsQueryable().Where(t => !(t.FirstName.IndexOf("VI", StringComparison.OrdinalIgnoreCase) == -1)); + QueryableAssert.AreEqual(a, b, "CaseInsensitive"); + } + [TestMethod] public void StartsWith() { diff --git a/PoweredSoft.DynamicLinq/Fluent/Where/WhereBuilder.shortcuts.cs b/PoweredSoft.DynamicLinq/Fluent/Where/WhereBuilder.shortcuts.cs index a1439a6..4a04207 100644 --- a/PoweredSoft.DynamicLinq/Fluent/Where/WhereBuilder.shortcuts.cs +++ b/PoweredSoft.DynamicLinq/Fluent/Where/WhereBuilder.shortcuts.cs @@ -98,14 +98,14 @@ namespace PoweredSoft.DynamicLinq.Fluent #endregion #region not contains - public WhereBuilder NotContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null) - => And(path, ConditionOperators.NotContains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision); + public WhereBuilder NotContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false) + => And(path, ConditionOperators.NotContains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate); - public WhereBuilder AndNotContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null) - => And(path, ConditionOperators.NotContains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision); + public WhereBuilder AndNotContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false) + => And(path, ConditionOperators.NotContains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate); - public WhereBuilder OrNotContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null) - => Or(path, ConditionOperators.NotContains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision); + public WhereBuilder OrNotContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false) + => Or(path, ConditionOperators.NotContains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate); #endregion #region starts with