all tests are passing, negate and not contains feature.
This commit is contained in:
parent
84e111ee80
commit
c45ff785bc
@ -180,7 +180,7 @@ namespace PoweredSoft.DynamicLinq.Test
|
|||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void NotContains()
|
public void NotContains2()
|
||||||
{
|
{
|
||||||
var q1 = Persons.AsQueryable().Query(t => t.NotContains("LastName", "ee"));
|
var q1 = Persons.AsQueryable().Query(t => t.NotContains("LastName", "ee"));
|
||||||
var q1b = Persons.AsQueryable().Where(t => !t.LastName.Contains("ee"));
|
var q1b = Persons.AsQueryable().Where(t => !t.LastName.Contains("ee"));
|
||||||
|
@ -76,6 +76,22 @@ namespace PoweredSoft.DynamicLinq.Test
|
|||||||
QueryableAssert.AreEqual(a, b, "CaseInsensitive");
|
QueryableAssert.AreEqual(a, b, "CaseInsensitive");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void NegateNotContains()
|
||||||
|
{
|
||||||
|
IQueryable<MockPersonObject> 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]
|
[TestMethod]
|
||||||
public void StartsWith()
|
public void StartsWith()
|
||||||
{
|
{
|
||||||
|
@ -98,14 +98,14 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region not contains
|
#region not contains
|
||||||
public WhereBuilder NotContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
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);
|
=> 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)
|
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);
|
=> 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)
|
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);
|
=> Or(path, ConditionOperators.NotContains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region starts with
|
#region starts with
|
||||||
|
Loading…
Reference in New Issue
Block a user