Merge branch 'master' into master

This commit is contained in:
Biarity
2018-05-25 18:07:19 +10:00
committed by GitHub
5 changed files with 96 additions and 5 deletions

View File

@@ -137,10 +137,12 @@ namespace Sieve.Services
if (property != null)
{
var converter = TypeDescriptor.GetConverter(property.PropertyType);
dynamic filterValue = Expression.Constant(
converter.CanConvertFrom(typeof(string))
? converter.ConvertFrom(filterTerm.Value)
: Convert.ChangeType(filterTerm.Value, property.PropertyType));
dynamic constantVal = converter.CanConvertFrom(typeof(string))
? converter.ConvertFrom(filterTerm.Value)
: Convert.ChangeType(filterTerm.Value, property.PropertyType);
Expression filterValue = GetClosureOverConstant(constantVal);
dynamic propertyValue = Expression.PropertyOrField(parameterExpression, property.Name);
@@ -217,6 +219,14 @@ namespace Sieve.Services
}
}
//Workaround to ensure that the filter value gets passed as a parameter in generated SQL from EF Core
//See https://github.com/aspnet/EntityFrameworkCore/issues/3361
private Expression GetClosureOverConstant<T>(T constant)
{
Expression<Func<T>> closure = () => constant;
return closure.Body;
}
private IQueryable<TEntity> ApplySorting<TEntity>(
ISieveModel<IFilterTerm, ISortTerm> model,
IQueryable<TEntity> result,