How can I update entity partly in WCF Data Services

594 Views Asked by At

I`m looking how can I update the part of entity via WCF Data Services 5.5, just update several field insted of whole entity.

I found several ways.

  1. I can update whole entity using context.AttachTo(...); and context.UpdateObject(tp); But all the entity's fields will be updated. I would like to update just only some fields.

  2. Add some logic to RequestPipeline and remove fields which shouldn't update, as described on the following blog: http://blogs.msdn.com/b/astoriateam/archive/2013/07/26/using-the-new-client-hooks-in-wcf-data-services-client.aspx

  3. Create the request manually.

Are there any other ways to do this? Is there a way to configure System.Data.Services.Client.DataServiceContext to turn on partial updates?

1

There are 1 best solutions below

0
On

Most clients use HTTP PATCH by default, which is used in OData and supported by the WCF Data Services implementation (previously as MERGE, before PATCH was specified).

From your question however, it looks as though you're wondering about doing a partial update from your server to your DBMS, and not from the client to the server. It also seems that you're using the Entity Framework provider. If that's correct, I suggest you ask your question using the entity-framework tag, and strip it from any reference to WCF Data Services, as it's not really related.