supporting negate.
This commit is contained in:
parent
e97fd56746
commit
5f9d5ca715
@ -170,5 +170,13 @@ namespace PoweredSoft.DynamicLinq.Test
|
|||||||
var q3b = Persons.AsQueryable().Where(t => t.LastName.Contains("ee") || t.LastName.Contains("ar"));
|
var q3b = Persons.AsQueryable().Where(t => t.LastName.Contains("ee") || t.LastName.Contains("ar"));
|
||||||
QueryableAssert.AreEqual(q3, q3b);
|
QueryableAssert.AreEqual(q3, q3b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void NotContains()
|
||||||
|
{
|
||||||
|
var q1 = Persons.AsQueryable().Query(t => t.Contains("LastName", "ee", negate: true));
|
||||||
|
var q1b = Persons.AsQueryable().Where(t => !t.LastName.Contains("ee"));
|
||||||
|
QueryableAssert.AreEqual(q1, q1b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
|
|
||||||
public virtual WhereBuilder Compare(string path, ConditionOperators conditionOperators, object value,
|
public virtual WhereBuilder Compare(string path, ConditionOperators conditionOperators, object value,
|
||||||
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField,
|
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField,
|
||||||
bool and = true, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
bool and = true, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
{
|
{
|
||||||
Filters.Add(new WhereBuilderCondition
|
Filters.Add(new WhereBuilderCondition
|
||||||
{
|
{
|
||||||
@ -40,7 +40,8 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
Value = value,
|
Value = value,
|
||||||
ConvertStrategy = convertStrategy,
|
ConvertStrategy = convertStrategy,
|
||||||
CollectionHandling = collectionHandling,
|
CollectionHandling = collectionHandling,
|
||||||
StringComparisation = stringComparision
|
StringComparisation = stringComparision,
|
||||||
|
Negate = negate
|
||||||
});
|
});
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@ -131,7 +132,8 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
filter.CollectionHandling,
|
filter.CollectionHandling,
|
||||||
parameter: parameter,
|
parameter: parameter,
|
||||||
nullChecking: IsNullCheckingEnabled,
|
nullChecking: IsNullCheckingEnabled,
|
||||||
stringComparision: filter.StringComparisation
|
stringComparision: filter.StringComparisation,
|
||||||
|
negate: filter.Negate
|
||||||
);
|
);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -7,12 +7,12 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
public partial class WhereBuilder
|
public partial class WhereBuilder
|
||||||
{
|
{
|
||||||
public WhereBuilder And(string path, ConditionOperators conditionOperator, object value,
|
public WhereBuilder And(string path, ConditionOperators conditionOperator, object value,
|
||||||
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> Compare(path, conditionOperator, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, and: true, stringComparision: stringComparision);
|
=> Compare(path, conditionOperator, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, and: true, stringComparision: stringComparision, negate: negate);
|
||||||
|
|
||||||
public WhereBuilder Or(string path, ConditionOperators conditionOperator, object value,
|
public WhereBuilder Or(string path, ConditionOperators conditionOperator, object value,
|
||||||
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> Compare(path, conditionOperator, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, and: false, stringComparision: stringComparision);
|
=> Compare(path, conditionOperator, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, and: false, stringComparision: stringComparision, negate: negate);
|
||||||
|
|
||||||
public WhereBuilder And(Action<WhereBuilder> subQuery)
|
public WhereBuilder And(Action<WhereBuilder> subQuery)
|
||||||
=> SubQuery(subQuery, true);
|
=> SubQuery(subQuery, true);
|
||||||
@ -21,25 +21,25 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
=> SubQuery(subQuery, false);
|
=> SubQuery(subQuery, false);
|
||||||
|
|
||||||
#region equal
|
#region equal
|
||||||
public WhereBuilder Equal(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder Equal(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> And(path, ConditionOperators.Equal, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.Equal, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
|
|
||||||
public WhereBuilder AndEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder AndEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> And(path, ConditionOperators.Equal, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.Equal, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
|
|
||||||
public WhereBuilder OrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder OrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> Or(path, ConditionOperators.Equal, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> Or(path, ConditionOperators.Equal, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region not equal
|
#region not equal
|
||||||
public WhereBuilder NotEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder NotEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> And(path, ConditionOperators.NotEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.NotEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
|
|
||||||
public WhereBuilder AndNotEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder AndNotEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> And(path, ConditionOperators.NotEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.NotEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
|
|
||||||
public WhereBuilder OrNotEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder OrNotEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> Or(path, ConditionOperators.NotEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> Or(path, ConditionOperators.NotEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region GreaterThan
|
#region GreaterThan
|
||||||
@ -87,36 +87,36 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region contains
|
#region contains
|
||||||
public WhereBuilder Contains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder Contains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> And(path, ConditionOperators.Contains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.Contains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
|
|
||||||
public WhereBuilder AndContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder AndContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> And(path, ConditionOperators.Contains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.Contains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
|
|
||||||
public WhereBuilder OrContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder OrContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> Or(path, ConditionOperators.Contains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> Or(path, ConditionOperators.Contains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region starts with
|
#region starts with
|
||||||
public WhereBuilder StartsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder StartsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> And(path, ConditionOperators.StartsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.StartsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
|
|
||||||
public WhereBuilder AndStartsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder AndStartsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> And(path, ConditionOperators.StartsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.StartsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
|
|
||||||
public WhereBuilder OrStartsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder OrStartsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> Or(path, ConditionOperators.StartsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> Or(path, ConditionOperators.StartsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ends with
|
#region ends with
|
||||||
public WhereBuilder EndsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder EndsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> And(path, ConditionOperators.EndsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.EndsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
|
|
||||||
public WhereBuilder AndEndsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder AndEndsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> And(path, ConditionOperators.EndsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.EndsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
|
|
||||||
public WhereBuilder OrEndsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder OrEndsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null, bool negate = false)
|
||||||
=> Or(path, ConditionOperators.EndsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> Or(path, ConditionOperators.EndsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision, negate: negate);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region In
|
#region In
|
||||||
|
@ -16,5 +16,6 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
public List<WhereBuilderCondition> Conditions { get; set; } = new List<WhereBuilderCondition>();
|
public List<WhereBuilderCondition> Conditions { get; set; } = new List<WhereBuilderCondition>();
|
||||||
public QueryCollectionHandling CollectionHandling { get; set; }
|
public QueryCollectionHandling CollectionHandling { get; set; }
|
||||||
public StringComparison? StringComparisation { get; set; } = null;
|
public StringComparison? StringComparisation { get; set; } = null;
|
||||||
|
public bool Negate { get; set; } = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace PoweredSoft.DynamicLinq.Helpers
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Expression GetConditionExpressionForMember(ParameterExpression parameter, Expression member, ConditionOperators conditionOperator, ConstantExpression constant, StringComparison? stringComparision)
|
public static Expression GetConditionExpressionForMember(ParameterExpression parameter, Expression member, ConditionOperators conditionOperator, ConstantExpression constant, StringComparison? stringComparision, bool negate)
|
||||||
{
|
{
|
||||||
if (parameter == null)
|
if (parameter == null)
|
||||||
throw new ArgumentNullException("parameter");
|
throw new ArgumentNullException("parameter");
|
||||||
@ -78,6 +78,9 @@ namespace PoweredSoft.DynamicLinq.Helpers
|
|||||||
else
|
else
|
||||||
throw new ArgumentException("conditionOperator", "Must supply a known condition operator");
|
throw new ArgumentException("conditionOperator", "Must supply a known condition operator");
|
||||||
|
|
||||||
|
if (negate)
|
||||||
|
ret = Expression.Not(ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,7 +439,7 @@ namespace PoweredSoft.DynamicLinq.Helpers
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
internal static Expression InternalCreateConditionExpression(int recursionStep, Type type, ParameterExpression parameter, Expression current, List<string> parts,
|
internal static Expression InternalCreateConditionExpression(int recursionStep, Type type, ParameterExpression parameter, Expression current, List<string> parts,
|
||||||
ConditionOperators condition, object value, QueryConvertStrategy convertStrategy, QueryCollectionHandling collectionHandling, bool nullChecking, StringComparison? stringComparison)
|
ConditionOperators condition, object value, QueryConvertStrategy convertStrategy, QueryCollectionHandling collectionHandling, bool nullChecking, StringComparison? stringComparison, bool negate)
|
||||||
{
|
{
|
||||||
var partStr = parts.First();
|
var partStr = parts.First();
|
||||||
var isLast = parts.Count == 1;
|
var isLast = parts.Count == 1;
|
||||||
@ -460,7 +463,7 @@ namespace PoweredSoft.DynamicLinq.Helpers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var constant = QueryableHelpers.ResolveConstant(memberExpression, value, convertStrategy);
|
var constant = QueryableHelpers.ResolveConstant(memberExpression, value, convertStrategy);
|
||||||
var filterExpression = QueryableHelpers.GetConditionExpressionForMember(parameter, memberExpression, condition, constant, stringComparison);
|
var filterExpression = QueryableHelpers.GetConditionExpressionForMember(parameter, memberExpression, condition, constant, stringComparison, negate);
|
||||||
var lambda = Expression.Lambda(filterExpression, parameter);
|
var lambda = Expression.Lambda(filterExpression, parameter);
|
||||||
return lambda;
|
return lambda;
|
||||||
}
|
}
|
||||||
@ -475,7 +478,7 @@ namespace PoweredSoft.DynamicLinq.Helpers
|
|||||||
{
|
{
|
||||||
var listGenericArgumentType = memberExpression.Type.GetGenericArguments().First();
|
var listGenericArgumentType = memberExpression.Type.GetGenericArguments().First();
|
||||||
var innerParameter = Expression.Parameter(listGenericArgumentType, $"t{++recursionStep}");
|
var innerParameter = Expression.Parameter(listGenericArgumentType, $"t{++recursionStep}");
|
||||||
var innerLambda = InternalCreateConditionExpression(recursionStep, listGenericArgumentType, innerParameter, innerParameter, parts.Skip(1).ToList(), condition, value, convertStrategy, collectionHandling, nullChecking, stringComparison);
|
var innerLambda = InternalCreateConditionExpression(recursionStep, listGenericArgumentType, innerParameter, innerParameter, parts.Skip(1).ToList(), condition, value, convertStrategy, collectionHandling, nullChecking, stringComparison, negate);
|
||||||
|
|
||||||
// the collection method.
|
// the collection method.
|
||||||
var collectionMethod = GetCollectionMethod(collectionHandling);
|
var collectionMethod = GetCollectionMethod(collectionHandling);
|
||||||
@ -494,14 +497,14 @@ namespace PoweredSoft.DynamicLinq.Helpers
|
|||||||
{
|
{
|
||||||
if (nullCheckExpression != null)
|
if (nullCheckExpression != null)
|
||||||
{
|
{
|
||||||
var pathExpr = InternalCreateConditionExpression(recursionStep, type, parameter, memberExpression, parts.Skip(1).ToList(), condition, value, convertStrategy, collectionHandling, nullChecking, stringComparison);
|
var pathExpr = InternalCreateConditionExpression(recursionStep, type, parameter, memberExpression, parts.Skip(1).ToList(), condition, value, convertStrategy, collectionHandling, nullChecking, stringComparison, negate);
|
||||||
|
|
||||||
var nullCheckResult = Expression.AndAlso(nullCheckExpression, (pathExpr as LambdaExpression).Body);
|
var nullCheckResult = Expression.AndAlso(nullCheckExpression, (pathExpr as LambdaExpression).Body);
|
||||||
var nullCheckResultLambda = Expression.Lambda((Expression)nullCheckResult, parameter);
|
var nullCheckResultLambda = Expression.Lambda((Expression)nullCheckResult, parameter);
|
||||||
return nullCheckResultLambda;
|
return nullCheckResultLambda;
|
||||||
}
|
}
|
||||||
|
|
||||||
return InternalCreateConditionExpression(recursionStep, type, parameter, memberExpression, parts.Skip(1).ToList(), condition, value, convertStrategy, collectionHandling, nullChecking, stringComparison);
|
return InternalCreateConditionExpression(recursionStep, type, parameter, memberExpression, parts.Skip(1).ToList(), condition, value, convertStrategy, collectionHandling, nullChecking, stringComparison, negate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,13 +563,14 @@ namespace PoweredSoft.DynamicLinq.Helpers
|
|||||||
QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any,
|
QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any,
|
||||||
ParameterExpression parameter = null,
|
ParameterExpression parameter = null,
|
||||||
bool nullChecking = false,
|
bool nullChecking = false,
|
||||||
StringComparison? stringComparision = null)
|
StringComparison? stringComparision = null, bool negate = false)
|
||||||
{
|
{
|
||||||
var ret = CreateConditionExpression(typeof(T), path, condition, value, convertStrategy,
|
var ret = CreateConditionExpression(typeof(T), path, condition, value, convertStrategy,
|
||||||
collectionHandling: collectionHandling,
|
collectionHandling: collectionHandling,
|
||||||
parameter: parameter,
|
parameter: parameter,
|
||||||
nullChecking: nullChecking,
|
nullChecking: nullChecking,
|
||||||
stringComparision: stringComparision) as Expression<Func<T, bool>>;
|
stringComparision: stringComparision,
|
||||||
|
negate: negate) as Expression<Func<T, bool>>;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,13 +582,14 @@ namespace PoweredSoft.DynamicLinq.Helpers
|
|||||||
QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any,
|
QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any,
|
||||||
ParameterExpression parameter = null,
|
ParameterExpression parameter = null,
|
||||||
bool nullChecking = false,
|
bool nullChecking = false,
|
||||||
StringComparison? stringComparision = null)
|
StringComparison? stringComparision = null,
|
||||||
|
bool negate = false)
|
||||||
{
|
{
|
||||||
if (parameter == null)
|
if (parameter == null)
|
||||||
parameter = Expression.Parameter(type, "t");
|
parameter = Expression.Parameter(type, "t");
|
||||||
|
|
||||||
var parts = path.Split('.').ToList();
|
var parts = path.Split('.').ToList();
|
||||||
var result = InternalCreateConditionExpression(1, type, parameter, parameter, parts, condition, value, convertStrategy, collectionHandling, nullChecking, stringComparision);
|
var result = InternalCreateConditionExpression(1, type, parameter, parameter, parts, condition, value, convertStrategy, collectionHandling, nullChecking, stringComparision, negate);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user