public static string ConvertToUriLiteral(object value, ODataVersion version, IEdmModel model) { if (value == null) { value = new ODataNullValue(); } if (model == null) { model = Microsoft.OData.Edm.EdmCoreModel.Instance; } ODataNullValue nullValue = value as ODataNullValue; if (nullValue != null) { return(ExpressionConstants.KeywordNull); } ODataCollectionValue collectionValue = value as ODataCollectionValue; if (collectionValue != null) { return(ODataUriConversionUtils.ConvertToUriCollectionLiteral(collectionValue, model, version)); } ODataEnumValue enumValue = value as ODataEnumValue; if (enumValue != null) { return(ODataUriConversionUtils.ConvertToUriEnumLiteral(enumValue, version)); } ODataResourceBase resource = value as ODataResourceBase; if (resource != null) { return(ODataUriConversionUtils.ConvertToUriEntityLiteral(resource, model)); } ODataEntityReferenceLink link = value as ODataEntityReferenceLink; if (link != null) { return(ODataUriConversionUtils.ConvertToUriEntityReferenceLiteral(link, model)); } ODataEntityReferenceLinks links = value as ODataEntityReferenceLinks; if (links != null) { return(ODataUriConversionUtils.ConvertToUriEntityReferencesLiteral(links, model)); } IEnumerable <ODataResourceBase> list = value as IEnumerable <ODataResourceBase>; if (list != null) { return(ODataUriConversionUtils.ConvertToUriEntitiesLiteral(list, model)); } // Try to convert uints to their underlying type first according to the model. value = model.ConvertToUnderlyingTypeIfUIntValue(value); return(ODataUriConversionUtils.ConvertToUriPrimitiveLiteral(value, version)); }
/// <summary> /// Asynchronously writes the result of a $ref query as the message payload. /// </summary> /// <param name="links">The entity reference links to write as message payload.</param> /// <returns>A task representing the asynchronous writing of the entity reference links.</returns> /// <remarks>It is the responsibility of this method to flush the output before the task finishes.</remarks> internal virtual Task WriteEntityReferenceLinksAsync(ODataEntityReferenceLinks links) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.EntityReferenceLinks); }