From b4eb70b863d7eb9cb005a7b6b2dc38f5132c41b1 Mon Sep 17 00:00:00 2001 From: jods Date: Mon, 22 May 2023 19:23:50 +0200 Subject: [PATCH] Fix #560 --- .../RequestWriter.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Simple.OData.Client.V4.Adapter/RequestWriter.cs b/src/Simple.OData.Client.V4.Adapter/RequestWriter.cs index 9e61a01a..090103f5 100644 --- a/src/Simple.OData.Client.V4.Adapter/RequestWriter.cs +++ b/src/Simple.OData.Client.V4.Adapter/RequestWriter.cs @@ -403,10 +403,10 @@ await entryWriter.WriteStartAsync(new ODataNestedResourceInfo() var linkKey = linkTypeWithKey.DeclaredKey; var linkEntry = referenceLink.LinkData.ToDictionary(TypeCache); var contentId = GetContentId(referenceLink); - string linkUri; + Url linkUrl; if (contentId != null) { - linkUri = "$" + contentId; + linkUrl = new Uri("$" + contentId, UriKind.Relative); } else { @@ -414,13 +414,11 @@ await entryWriter.WriteStartAsync(new ODataNestedResourceInfo() linkKey.ToDictionary(x => x.Name, x => linkEntry[x.Name]), true); var linkedCollectionName = _session.Metadata.GetLinkedCollectionName( referenceLink.LinkData.GetType().Name, linkTypeWithKey.Name, out var isSingleton); - linkUri = linkedCollectionName + (isSingleton ? string.Empty : formattedKey); + var linkUri = linkedCollectionName + (isSingleton ? string.Empty : formattedKey); + linkUrl = Utils.CreateAbsoluteUri(_session.Settings.BaseUri.AbsoluteUri, linkUri); } - var link = new ODataEntityReferenceLink - { - Url = Utils.CreateAbsoluteUri(_session.Settings.BaseUri.AbsoluteUri, linkUri) - }; + var link = new ODataEntityReferenceLink { Url = linkUrl }; await entryWriter.WriteEntityReferenceLinkAsync(link).ConfigureAwait(false); } @@ -676,4 +674,4 @@ public static bool TryConvert(object value, Type targetType, out object? result) } .ToDictionary(kvp => kvp.Key, kvp => kvp.Value); } -} \ No newline at end of file +}