简体   繁体   中英

Issue implementing child class method

So I'm having a bit of a problem... the thing is that I have a base class that has implementation for all GET/POST/PUT/DELETE and it's a Generic class so basically whatever I Entity I update passes through there and then I have a class for my entities that implements that class...

public virtual async Task<IHttpActionResult> Put([FromODataUri] TKey key)

The thing is that for one of the Entities I want to implement additional logic before updating the database so I thought I just do it on the child class and then after that new logic I call the base class method and that should do the trick so I created an overloaded method

public override Task<IHttpActionResult> Put(int key){
     //NEW LOGIC
     return base.Put(key);
}

The problem that I'm having is that when I do the request from the Client, if I don't have this new method implemented it works fine and calls the base clase method and the Entity is updated but after I added this, using exactly the same ajax request it returns a 400 response... Can anyone help me out figuring out what's going on? Thanks a lot :)

Here is extract from the document

1.4.3 Update an Entity . . . Services MAY additionally support PUT, but should be aware of the potential for data-loss in round-tripping properties that the client may not know about in advance, such as open or added properties, or properties not specified in metadata. Services that support PUT MUST replace all values of structural properties with those specified in the request body . . . .

I guarantee you that OData can't resolve the route you supplied because it is looking for PUT with model as parameter and then also, you can have key. Hence, you get error #400.

I don't know, even, if using ODataRouteAttribute will help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM