Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PATCH to a complex type. #135

Closed
LianwMS opened this issue Jan 12, 2015 · 25 comments
Closed

Support PATCH to a complex type. #135

LianwMS opened this issue Jan 12, 2015 · 25 comments
Assignees
Labels
Milestone

Comments

@LianwMS
Copy link
Contributor

LianwMS commented Jan 12, 2015

Now we the Delta class only supports Entity type, but the protocol also
supports PATCH to a complex type:

11.4.9.3 Update a Complex Type

A successful PATCH request to the edit URL for a complex typed property updates that property. The request body MUST contain a single valid representation for the target complex type.
The service MUST directly modify only those properties of the complex type specified in the payload of the PATCH request.

Work Item Details

Original CodePlex Issue: Issue 2066
Status: Proposed
Reason Closed: Unassigned
Assigned to: Unassigned
Reported on: Jul 16, 2014 at 4:02 AM
Reported by: jinfutan
Updated on: Oct 20, 2014 at 7:28 PM
Updated by: abatishchev

@LianwMS
Copy link
Contributor Author

LianwMS commented Jan 12, 2015

On 2014-10-14 21:20:55 UTC, skotapati commented:

Just wondering when will this feature be available in WebAPI/OData?

@LianwMS LianwMS added this to the vNext milestone Jan 12, 2015
@sammym1982
Copy link

Is this being worked upon?

@Tornhoof
Copy link

Tornhoof commented Jun 5, 2015

+1 on this. Using complex types simplifies the data models, especially for nested structures

@ashelley
Copy link

+1 on this. Not being able to patch nested objects is a big limitation.

@zizzex
Copy link

zizzex commented Nov 19, 2015

Without nested objects this feature is unfortunately almost useless.
Is there any prevision of a possible availability date? Thanks.

@RavindraBarapatre
Copy link

Below is my Address entity, it has PostalAddress as nested entity, I am trying to do patch update.
{
"CareOf": "Updated",
"BehalfOf": "BehalfOf updated",
"PostalAddress": {
"Id": "9bd27f41-e093-46ce-8d51-10ba7e2e3e13",
"PoBox": "12121",
"PostalCode": "12121"
}
}
when I debug odata service I received Delta patch = null.

If I pass simple object it works.
{
"CareOf": "Updated",
"BehalfOf": "BehalfOf updated"
}

is it because Delta not support nested object or Patch in Odata service is not supporting it.

@shaungrech
Copy link

Hi,

As far as I know at the moment OData Web API does not support Patch within
nested objects.

Shaun

On Wed, Dec 23, 2015 at 1:29 PM, RavindraBarapatre <notifications@github.com

wrote:

Below is my Address entity, it has PostalAddress as nested entity, I am
trying to do patch update.
{
"CareOf": "Updated",
"BehalfOf": "BehalfOf updated",
"PostalAddress": {
"Id": "9bd27f41-e093-46ce-8d51-10ba7e2e3e13",
"PoBox": "12121",
"PostalCode": "12121"
}
}
when I debug odata service I received Delta patch = null.

If I pass simple object it works.
{
"CareOf": "Updated",
"BehalfOf": "BehalfOf updated"
}

is it because Delta not support nested object or Patch in Odata service is
not supporting it.


Reply to this email directly or view it on GitHub
#135 (comment).

Regards,

Shaun Grech Co-Founder, Incredible Web / Bum a Lift
79886164
shaun.grech@incredible-web.com
www.incredible-web.com
www.bumalift.com http://www.incredible-web.com/

@RavindraBarapatre
Copy link

Ohhh .. :(
is there any workaround?

@sgankum
Copy link

sgankum commented Dec 23, 2015

without supporting nested objects, i believe this is not an useful one.
Kindly let us know the workaround for this

@xuzhg xuzhg modified the milestones: v5.9, v5.8 Jan 6, 2016
@lelong37
Copy link

+100

xuzhg added a commit to xuzhg/WebApi that referenced this issue Feb 1, 2016
@xuzhg
Copy link
Member

xuzhg commented Feb 1, 2016

Dear customers, Would you please help me try the [PR]#623 and give me some feedback?

I would like to put it into 5.9 beta so customers can use it from nightly build. Thanks.

xuzhg added a commit to xuzhg/WebApi that referenced this issue Feb 3, 2016
xuzhg added a commit that referenced this issue Feb 3, 2016
@xuzhg
Copy link
Member

xuzhg commented Feb 3, 2016

I merged my fix. Anyone who try it and find any issue, please reopen it or file a new issue for us. Thanks in advance.

@xuzhg xuzhg closed this as completed Feb 3, 2016
xuzhg added a commit to xuzhg/WebApi that referenced this issue Mar 4, 2016
@egbertn
Copy link

egbertn commented Mar 20, 2017

package id="Microsoft.OData.Core" version="7.0.0" targetFramework="net462"
package id="Microsoft.OData.Edm" version="7.0.0" targetFramework="net462"

These packages are totally different compared with 5.9.x
Will the patch be fixed in those as well?

@bkwdesign
Copy link

I can't even get my odata v4 api controller to support PATCHing of my main entity

Have no idea how to get an ajax PATCH request to work.. always get a null at my controller's 'delta' parameter

NuGet packages:
id="Microsoft.AspNet.OData" version="6.0.0"
id="Microsoft.OData.Core" version="7.0.0"
id="Microsoft.OData.Edm" version="7.0.0"

@egbertn
Copy link

egbertn commented Mar 20, 2017

Important is the body and the URL syntax e.g.

public async Task<IHttpActionResult> Patch(Guid key, [DeltaBody] Data.OData.Delta<company> delta)

Second, I copied Delta from the Github 5.9 libraries, that are more recent than the 7.0 libraries and 'renamed' the namespace so I got it working, more or less.
DeltaBody is my own attribute
to intercept the raw message and I use NewtonSoft to deserialize the message, so the complex type will be patched too! This has side effects, because OData serialisation is simply not the same, but it works, in my case.
drop a message to my profile, if you want the source for the 'delta workaround'.

@olumyde777
Copy link

Hi Egbertn,
Please I need the source code for the 'delta workaround'.
My email address is olumyde77@yahoo.com
Thanks

@olumyde777
Copy link

Hi Egbertn,
Thanks for the source code.
It worked for me. You have really helped to solve a problem I had been on it for almost 5 months.
Thanks once again.

@bkwdesign
Copy link

Yes, we are currently using it in all our projects for several months now- I've put your code into a standalone assembly that I can reference in each WebAPI project

@yuhong-l
Copy link

yuhong-l commented Nov 20, 2018

I guess this issue is still not resolved? If so, which version? Try 6.1/7.0 failed.
We could only patch nested plain object without a key defined.
It wouldn't suppor entity like:

{
"id": "[guid]"
"name": "My Company",
"addresses": [{"id":"assa", "address": "siliconroad", "number": 123, "city": "LA", "zipcode": "2134324" }]
}

@Razgort
Copy link

Razgort commented Feb 27, 2019

Is it possible to do a patch method without delta ? only with type ?

@xuzhg
Copy link
Member

xuzhg commented Feb 27, 2019

@Razgort see #1775

@Razgort
Copy link

Razgort commented Mar 1, 2019

Yes i opened new issue about that

@egbertn
Copy link

egbertn commented Mar 3, 2019

Here, again, it should not be done like this. References must be updated by item directly

Odata 'assumes' that a SQL database is used at the background, so in a database world, the one side of the relation, is and should be updated. The many side, just contains a reference to a primary / foreign key.
But still, if you badly want that feature, yes, I made such an attempt for .NET Core. It seems to work, though, I don't have a lot of time to support it.
https://github.com/egbertn/ODataDelta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests