Commit 46e23d70 authored by thienvo's avatar thienvo

fixed

parent 8df59de9
...@@ -477,6 +477,7 @@ namespace Sieve.Services ...@@ -477,6 +477,7 @@ namespace Sieve.Services
} }
outerExpression = Expression.And(outerExpression, innerExpression); outerExpression = Expression.And(outerExpression, innerExpression);
} }
var data = outerExpression == null var data = outerExpression == null
? result ? result
: result.Where(Expression.Lambda<Func<TEntity, bool>>(outerExpression, parameterExpression)); : result.Where(Expression.Lambda<Func<TEntity, bool>>(outerExpression, parameterExpression));
...@@ -524,15 +525,16 @@ namespace Sieve.Services ...@@ -524,15 +525,16 @@ namespace Sieve.Services
case FilterOperator.LessThanOrEqualTo: case FilterOperator.LessThanOrEqualTo:
return Expression.LessThanOrEqual(propertyValue, filterValue); return Expression.LessThanOrEqual(propertyValue, filterValue);
case FilterOperator.Contains: case FilterOperator.Contains:
return Expression.Call(propertyValue, //fixed bug has null in data
return Expression.AndAlso(Expression.NotEqual(propertyValue, Expression.Constant(null, typeof(object))), Expression.Call(propertyValue,
typeof(string).GetMethods() typeof(string).GetMethods()
.First(m => m.Name == "Contains" && m.GetParameters().Length == 1), .First(m => m.Name == "Contains" && m.GetParameters().Length == 1),
filterValue); filterValue));
case FilterOperator.StartsWith: case FilterOperator.StartsWith:
return Expression.Call(propertyValue, return Expression.AndAlso(Expression.NotEqual(propertyValue, Expression.Constant(null, typeof(object))), Expression.Call(propertyValue,
typeof(string).GetMethods() typeof(string).GetMethods()
.First(m => m.Name == "StartsWith" && m.GetParameters().Length == 1), .First(m => m.Name == "StartsWith" && m.GetParameters().Length == 1),
filterValue); filterValue));
default: default:
return Expression.Equal(propertyValue, filterValue); return Expression.Equal(propertyValue, filterValue);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment