OData / WebApi

OData Web API: A server library built upon ODataLib and WebApi
https://docs.microsoft.com/odata
Other
855 stars 473 forks source link

Patch without using delta<T> #1775

Open Razgort opened 5 years ago

Razgort commented 5 years ago

Hello guys,

Would it be possible to route my patch method without delta or a delta in aspcore?

xuzhg commented 5 years ago

@Razgort It should work (can you test it). But, if you use type instance directly, not use Delta, you can't know which property is really changed.

Razgort commented 5 years ago

I dont mind knowing what property changed since i will call a stored procedure inside the function that will do the job anyway.

But i can't get any of these route working :

    //public IActionResult Patch([FromODataUri] int key, Delta<JObject> delta)
    //public IActionResult Patch([FromODataUri] int key, JObject Jobj)

    //public IActionResult Patch([FromODataUri] int key, V_SI_GESTION_TEMPS_WEB Jobj)

The only one i can get working is

    public IActionResult Patch([FromODataUri] int key, Delta<V_SI_GESTION_TEMPS_WEB> delta)

All others above throw exception on server side ....

Razgort commented 5 years ago

is there something like this for asp, core http://technolog.nl/blogs/eprogrammer/archive/2017/04/30/OData-6.0.0-howto-fix-Cannot-apply-PATCH-to-navigation-property-_2700_x_2700_-on-entity-type_3F00_.aspx ?

egbertn commented 5 years ago

Disclaimer: Should not be used as a good practise! This breaks the Odata compliance of a REST api. https://github.com/egbertn/ODataDelta/