internal static object ConvertTo(ODataParameterValue parameterValue, HttpActionContext actionContext, ModelBindingContext bindingContext) { Contract.Assert(parameterValue != null && parameterValue.EdmType != null); object oDataValue = parameterValue.Value; if (oDataValue == null || oDataValue is ODataNullValue) { return(null); } IEdmTypeReference edmTypeReference = parameterValue.EdmType; ODataDeserializerContext readContext = BuildDeserializerContext(actionContext, bindingContext, edmTypeReference); // complex value ODataComplexValue complexValue = oDataValue as ODataComplexValue; if (complexValue != null) { IEdmComplexTypeReference edmComplexType = edmTypeReference.AsComplex(); Contract.Assert(edmComplexType != null); ODataComplexTypeDeserializer deserializer = (ODataComplexTypeDeserializer)DeserializerProvider.GetEdmTypeDeserializer(edmComplexType); return(deserializer.ReadInline(complexValue, edmComplexType, readContext)); } // collection of primitive, enum, complex ODataCollectionValue collectionValue = oDataValue as ODataCollectionValue; if (collectionValue != null) { return(ConvertCollection(collectionValue, edmTypeReference, bindingContext, readContext)); } // enum value ODataEnumValue enumValue = oDataValue as ODataEnumValue; if (enumValue != null) { IEdmEnumTypeReference edmEnumType = edmTypeReference.AsEnum(); Contract.Assert(edmEnumType != null); ODataEnumDeserializer deserializer = (ODataEnumDeserializer)DeserializerProvider.GetEdmTypeDeserializer(edmEnumType); return(deserializer.ReadInline(enumValue, edmEnumType, readContext)); } // primitive value if (edmTypeReference.IsPrimitive()) { return(EdmPrimitiveHelpers.ConvertPrimitiveValue(oDataValue, bindingContext.ModelType)); } // Entity, Feed, Entity Reference or collection of entity reference return(ConvertFeedOrEntry(oDataValue, edmTypeReference, readContext)); }