Nands
Nands

Reputation: 399

Delete record with composite primary key in OData

I have an entity Student. Below is the signature of delete method in ASP.net WebAPI for OData.

public async Task<IHttpActionResult> Delete([FromODataUri] int key)

The Student has composite primary key. When called from Postman, with

http://localhost:52484/Students/1

it doesn't hit the Delete method. But it works with other entity with single primary key.

Any suggestions?

Upvotes: 1

Views: 1749

Answers (1)

nandita morajkar
nandita morajkar

Reputation: 46

Kindly prefix param with 'key' for composite key Entity. OData v4

Refer the example below:

    public async Task<IHttpActionResult> Delete([FromODataUri] int keySudentId, [FromODataUri] int keyClassId)
    {
      //Delete code here
    }

OData Url http://localhost:52484/Student(SudentId=1,ClassId=2)

Upvotes: 3

Related Questions