Commit ed9a83e8 authored by thienvo's avatar thienvo

fixed sieve processor id>0 expression

parent 40ae5b61
...@@ -274,6 +274,21 @@ namespace Sieve.Services ...@@ -274,6 +274,21 @@ namespace Sieve.Services
return fullQueryString; return fullQueryString;
} }
protected object ChangeType(object value, Type conversion)
{
var t = conversion;
if (t.IsGenericType && t.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
{
if (value == null)
{
return null;
}
t = Nullable.GetUnderlyingType(t);
}
return Convert.ChangeType(value, t);
}
public Expression<Func<TEntity, bool>> GetFilterExpressionQuery<TEntity>( public Expression<Func<TEntity, bool>> GetFilterExpressionQuery<TEntity>(
TSieveModel model, TSieveModel model,
bool bCaseSensitive = false) bool bCaseSensitive = false)
...@@ -284,8 +299,9 @@ namespace Sieve.Services ...@@ -284,8 +299,9 @@ namespace Sieve.Services
if (model?.GetFiltersParsed() == null) if (model?.GetFiltersParsed() == null)
{ {
var property = Expression.Property(parameterExpression, "id"); var property = Expression.Property(parameterExpression, "id");
ConstantExpression constant = Expression.Constant(0, typeof(int)); ConstantExpression constant = Expression.Constant(this.ChangeType(0, property.Type), property.Type);
var rst = Expression.GreaterThan(property, constant); var rst = Expression.GreaterThan(property, constant);
return Expression.Lambda<Func<TEntity, bool>>(rst, parameterExpression); return Expression.Lambda<Func<TEntity, bool>>(rst, parameterExpression);
} }
......
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