OData / OData/AspNetCoreOData

How to Create and Delete References Between Entities

Open
#132 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

How do I post and put related entities. I have a Product entity for example with a Supplier navigation property. I would like to have an endpoint that allows to change the supplier for an existing product. Using odata I was able to make a post endpoint for the Product, but if I tried to include the supplier it had to be a new supplier, an existing one would through an error regarding the same primary key already exists. I am trying to allow posting an existing supplier and only binding it, without trying to create it.
I found a tutorial on microsoft.com, where they showed how to use CreateRef and DeleteRef. I tried to implement the same thing, but the endpoint wasn't even created. I assume the tutorial was for an earlier version, I am using odata 8.0.0-rc. I tried cloning the repository and running the sample project. But the above methods seem to not really be implemented (they return a string), and the endpoint is not mapped anyhow.
So, I am looking for an example on how to implement the above behavior. Any help would be appreciated, and I am sorry if I missed something obvious.
Thanks, Michael.

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.

Research direction

Start with the sample project and the CreateRef/DeleteRef implementation described in the issue, then inspect how its endpoints are mapped in the OData 8.0.0-rc setup. Confirm whether existing related entities can be bound without creation, and document or demonstrate the supported behavior when the endpoint mapping is complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.