OData / OData/AspNetCoreOData

CreateRef - link is null

Open
#562 1 comment 0 reactions 1 assignee View on GitHub

@KenitoInc is already working on this.

Since Apr 12, 2022.

followup
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

"link" parameter is null when CreateRef is called

Assemblies affected

Microsoft.AspNetCore.OData 8.0.8

Reproduce steps
    public class A
    {
        [Key]
        public int Id { get; set; }
        public B B { get; set; }
    }

    public class B
    {
        [Key]
        public int Id { get; set; }
        public string Value { get; set; }
    }

builder.EntitySet<A>("TestAs");
builder.EntitySet<B>("TestBs");

public class TestAsController : ODataController
{
  [AcceptVerbs("POST", "PUT")]
  public ActionResult CreateRef([FromODataUri] int key, string navigationProperty, [FromBody] Uri link)
  {
      return Accepted();
  }
}
http://localhost:52769/api/TestAs(1)/B/$ref
{"@odata.id":"http://localhost:52769/api/TestBs(2)"}
Expected result

key == 1, navigationProperty == "B", link == [link to B entity]

Actual result

key == 1, navigationProperty == "B", link == null

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.