Repository: dotnet/efcore
File: src/EFCore.Cosmos/Query/Internal/CosmosReadItemAndPartitionKeysExtractor.cs (C#)

Code before:
            case SqlBinaryExpression { OperatorType: ExpressionType.AndAlso } binary:
                return binary.Update((SqlExpression)Visit(binary.Left), (SqlExpression)Visit(binary.Right));

            default:
                // Anything else in the predicate, e.g. an OR, immediately disqualifies it from being a ReadItem query, and means we
                // can't extract partition key properties.
                _isPredicateCompatibleWithReadItem = false;
                return node;
        }

        void ProcessPropertyComparison(string propertyName, SqlExpression propertyValue, SqlExpression originalExpression)
        {
            // We assume that the comparison is incompatible with ReadItem until proven otherwise, i.e. the comparison is for a JSON ID
            // property, a partition key property, or certain cases involving the discriminator property.
            var isCompatibleComparisonForReadItem = false;

            if (propertyName == _discriminatorJsonPropertyName
                && propertyValue is SqlConstantExpression { Value: { } specifiedDiscriminatorValue }
                && _entityType.FindDiscriminatorProperty() is { } discriminatorProperty
                && _entityType.GetDiscriminatorValue() is { } entityDiscriminatorValue)
            {
                // Convert the specified discriminator value to provider value for comparison if there's a value converter
                var convertedSpecifiedValue = discriminatorProperty.GetValueConverter()?.ConvertToProvider(specifiedDiscriminatorValue) 
                    ?? specifiedDiscriminatorValue;
                
                if (discriminatorProperty.GetProviderValueComparer().Equals(convertedSpecifiedValue, entityDiscriminatorValue))
                {
                    // This is the case where there is a single leaf node with a discriminator value. We always know this value,
                    // so the query never needs to drop out of ReadItem because of it.
                    isCompatibleComparisonForReadItem = true;
                }
            }
            else
            {
                foreach (var property in _jsonIdPropertyValues.Keys)
                {
                    if (propertyName == property.GetJsonPropertyName())
                    {
                        if (_jsonIdPropertyValues.TryGetValue(property, out var previousValue)
                            && (previousValue is null || previousValue.Equals(propertyValue)))
                        {
                            _jsonIdPropertyValues[property] = propertyValue;
                            isCompatibleComparisonForReadItem = true;
                        }

                        break;
                    }
                }
            }

            foreach (var property in _partitionKeyPropertyValues.Keys)

Review comment (suggestion):
@copilot This isn't the right fix. You should just change `GetProviderValueComparer()` to `GetValueComparer())` and leave the rest of the code as it was

Code after:
            case SqlBinaryExpression { OperatorType: ExpressionType.AndAlso } binary:
                return binary.Update((SqlExpression)Visit(binary.Left), (SqlExpression)Visit(binary.Right));

            default:
                // Anything else in the predicate, e.g. an OR, immediately disqualifies it from being a ReadItem query, and means we
                // can't extract partition key properties.
                _isPredicateCompatibleWithReadItem = false;
                return node;
        }

        void ProcessPropertyComparison(string propertyName, SqlExpression propertyValue, SqlExpression originalExpression)
        {
            // We assume that the comparison is incompatible with ReadItem until proven otherwise, i.e. the comparison is for a JSON ID
            // property, a partition key property, or certain cases involving the discriminator property.
            var isCompatibleComparisonForReadItem = false;

            if (propertyName == _discriminatorJsonPropertyName
                && propertyValue is SqlConstantExpression { Value: { } specifiedDiscriminatorValue }
                && _entityType.FindDiscriminatorProperty() is { } discriminatorProperty
                && _entityType.GetDiscriminatorValue() is { } entityDiscriminatorValue
                && discriminatorProperty.GetValueComparer().Equals(specifiedDiscriminatorValue, entityDiscriminatorValue))
            {
                // This is the case where there is a single leaf node with a discriminator value. We always know this value,
                // so the query never needs to drop out of ReadItem because of it.
                isCompatibleComparisonForReadItem = true;
            }
            else
            {
                foreach (var property in _jsonIdPropertyValues.Keys)
                {
                    if (propertyName == property.GetJsonPropertyName())
                    {
                        if (_jsonIdPropertyValues.TryGetValue(property, out var previousValue)
                            && (previousValue is null || previousValue.Equals(propertyValue)))
                        {
                            _jsonIdPropertyValues[property] = propertyValue;
                            isCompatibleComparisonForReadItem = true;
                        }

                        break;
                    }
                }
            }

            foreach (var property in _partitionKeyPropertyValues.Keys)
            {
                // We found a comparison for a partition key property.
                // Extract its value expression and elide the comparison from the predicate - it'll be lifted out to the Cosmos SDK
                // call. Note that this is always considered a compatible comparison for ReadItem.
                if (propertyName == property.GetJsonPropertyName()
                    && _partitionKeyPropertyValues.TryGetValue(property, out var previousValues)