diff --git a/src/MR.EntityFrameworkCore.KeysetPagination/KeysetFilterPredicateStrategy.cs b/src/MR.EntityFrameworkCore.KeysetPagination/KeysetFilterPredicateStrategy.cs index a5cbeb1..28910e2 100644 --- a/src/MR.EntityFrameworkCore.KeysetPagination/KeysetFilterPredicateStrategy.cs +++ b/src/MR.EntityFrameworkCore.KeysetPagination/KeysetFilterPredicateStrategy.cs @@ -91,6 +91,8 @@ protected static BinaryExpression MakeComparisonExpression( } else { + // We call EnsureAdditionalConversions only when generating comparisons as these conversions + // are unneeded when generating an equality (Expression.Equal). return compare( EnsureAdditionalConversions(memberAccess), EnsureAdditionalConversions(EnsureMatchingType(memberAccess, referenceValue))); @@ -99,11 +101,11 @@ protected static BinaryExpression MakeComparisonExpression( private static Expression EnsureAdditionalConversions(Expression expression) { + // For enums, we need to convert to the underlying type for comparisons to work. if (expression.Type.IsEnum) { - var enumUnderlyingType = Enum.GetUnderlyingType(expression.Type); - - return Expression.Convert(expression, enumUnderlyingType); + var underlyingType = Enum.GetUnderlyingType(expression.Type); + return Expression.Convert(expression, underlyingType); } return expression;