diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightPropertyAndValueDeserializer.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightPropertyAndValueDeserializer.cs index 65afb9b87c..2208e54582 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightPropertyAndValueDeserializer.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightPropertyAndValueDeserializer.cs @@ -1523,8 +1523,25 @@ private object ReadEnumValue(bool insideJsonObjectValue, IEdmEnumTypeReference e throw new ODataException(ODataErrorStrings.JsonReaderExtensions_UnexpectedNodeDetectedWithPropertyName(JsonNodeType.PrimitiveValue, JsonNodeType.StartObject, propertyName)); } - string enumStr = this.JsonReader.ReadStringValue(); - return new ODataEnumValue(enumStr, expectedValueTypeReference.FullName()); + object enumValue = this.JsonReader.ReadPrimitiveValue(); + string enumString; + if (enumValue is int enumIntValue) + { + IEdmEnumType edmEnumType = expectedValueTypeReference.EnumDefinition(); + IEdmEnumMember selectedMember = edmEnumType.Members.FirstOrDefault(member => member.Value.Value == enumIntValue); + enumString = selectedMember.Name; + } + else if (enumValue is string enumStringValue) + { + enumString = enumStringValue; + } + else + { + throw new ODataException(ODataErrorStrings.ReaderValidationUtils_CannotConvertPrimitiveValue(enumValue, typeof(IEdmEnumTypeReference))); + } + + + return new ODataEnumValue(enumString, expectedValueTypeReference.FullName()); } ///