pass filter values as parameters (#112)

make GetClosureOverConstant really work
This commit is contained in:
alicak 2021-05-17 07:51:37 +02:00 committed by GitHub
parent 7a48ba8d61
commit ec6c310bf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -337,12 +337,10 @@ 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
// Expression.Constant passed the target type to allow Nullable comparison
// See http://bradwilson.typepad.com/blog/2008/07/creating-nullab.html
private static Expression GetClosureOverConstant<T>(T constant, Type targetType)
{
return Expression.Constant(constant, targetType);
Expression<Func<T>> hoistedConstant = () => constant;
return Expression.Convert(hoistedConstant.Body, targetType);
}
private IQueryable<TEntity> ApplySorting<TEntity>(TSieveModel model, IQueryable<TEntity> result,