OData / ODataSamples

Samples: For ODataLib, OData Web API, RESTier, etc.
http://odata.github.io/
Other
293 stars 222 forks source link

Navigation properties aren't working #124

Open TehWardy opened 4 years ago

TehWardy commented 4 years ago

I noticed that I can't get CreateRef or DeleteRef to work on any of my endpoints any more (this has come about since migrating to .Net Core I think) so I started to investigate where the issue was coming from and it seems that OData now doesn't respond to anything on any navigation links.

given a POST, PUT, or DELETE request to a url in the following format ...

~/Set(key)/navigation(childKey)

... I would expect one of these methods on my controller to be called "by default" as part of the default routing conventions / as part of attribute routing according to the documentation.

Controller Methods

[AcceptVerbs("POST", "PUT")]
[ODataRoute("({key})/{navigation}({childKey})")]
public virtual async Task<IActionResult> CreateLink([FromODataUri]TKey key, [FromODataUri]string navigation, [FromODataUri] object childKey)
{
    await Service.AddRelationship(key, navigation, childKey);
    return Ok();
}

[HttpDelete]
[ODataRoute("({key})/{navigation}({childKey})")]
public virtual async Task<IActionResult> DeleteLink([FromODataUri]TKey key, [FromODataUri]string navigation, [FromODataUri] object childKey)
{
    await Service.DeleteRelationship(key, navigation, childKey);

return Ok();
}

Documentation ... https://docs.microsoft.com/en-us/odata/webapi/attribute-routing

... that said this does only seem to apply to AspNet and not AspNet Core which completely empty.

Clearly I must be missing something here right? I'm seeing what appears to be a somewhat related dead ticket over at https://github.com/OData/WebApi/issues/1544 ... i don't know what this means though.