Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #560 #903

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/Simple.OData.Client.V4.Adapter/RequestWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,24 +403,22 @@ 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
{
var formattedKey = _session.Adapter.GetCommandFormatter().ConvertKeyValuesToUriLiteral(
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);
}
Expand Down Expand Up @@ -676,4 +674,4 @@ public static bool TryConvert(object value, Type targetType, out object? result)
}
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
}
}
}