1

我正在寻找如何通过 WCF Data Services 5.5 更新实体的一部分,只需更新整个实体的几个字段。

我找到了几种方法。

  1. 我可以使用context.AttachTo(...);和 更新整个实体,context.UpdateObject(tp);但所有实体的字段都将被更新。我只想更新一些字段。

  2. 添加一些逻辑RequestPipeline并删除不应更新的字段,如以下博客所述:http: //blogs.msdn.com/b/astoriateam/archive/2013/07/26/using-the-new-client-钩子在 wcf 数据服务client.aspx

  3. 手动创建请求。

还有其他方法可以做到这一点吗?有没有办法配置System.Data.Services.Client.DataServiceContext打开部分更新?

4

1 回答 1

0

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.

于 2013-08-06T16:56:42.570 回答