WriteReplace 和 WriteReplace 有什么区别? ADO.NET DataService 中的 WriteMerge?

发布于 2024-08-07 02:50:34 字数 1243 浏览 5 评论 0原文

我正在配置 ADO.NET DataService。

public static void InitializeService(IDataServiceConfiguration config)
{
    // config.UseVerboseErrors = true;
    // TODO: set rules to indicate which entity sets and service operations are
    //       visible, updatable, etc.
    // Examples:
    config.SetEntitySetAccessRule("User", EntitySetRights.WriteMerge);
    config.SetEntitySetAccessRule("User", EntitySetRights.WriteReplace);
}

我已阅读 EntitySetRights 枚举的 MSDN 页面 但我无法识别 EntitySetRights.WriteMerge 和 EntitySetRights.WriteReplace 之间的区别

我在 使用 Microsoft ADO.NET 数据服务

  • WriteMerge: 在基于合并的更新的情况下,有效负载需要是一个实体,并且只需要包含正在修改的属性。 如果未包含某个属性,则将保留服务器中当前存在的值。示例 14 显示了用于更新上一示例中插入的类别的有效负载。

  • 写入替换: 在基于替换的更新的情况下,有效负载需要是一个实体,并且应该包含该实体的所有属性(不包括导航属性)。 如果未包含某个属性,则该值将在服务器上重置为该属性的默认值。 PUT 请求的这种行为映射到 AtomPub RFC 5023 中描述的行为。示例 13 显示了用于更新在前面的插入示例中插入的类别的有效负载。由于并非所有属性都包含在有效负载中,因此未指定的属性将由数据服务重置为其默认值。

I am configuring an ADO.NET DataService.

public static void InitializeService(IDataServiceConfiguration config)
{
    // config.UseVerboseErrors = true;
    // TODO: set rules to indicate which entity sets and service operations are
    //       visible, updatable, etc.
    // Examples:
    config.SetEntitySetAccessRule("User", EntitySetRights.WriteMerge);
    config.SetEntitySetAccessRule("User", EntitySetRights.WriteReplace);
}

I have read the MSDN page for the EntitySetRights Enumeration but I can't identify the difference between EntitySetRights.WriteMerge and EntitySetRights.WriteReplace

I found the below explanation at Using Microsoft ADO.NET Data Services

  • WriteMerge:
    In the case of merge-based updates, the payload needs to be an entity and only needs to contain the properties that are being modified. If a property is not included, the value that is currently present in the server will be preserved. Example 14 shows the payload used to update the category that was inserted in the previous example.

  • WriteReplace:
    In the case of replace-based updates, the payload needs to be an entity and should contain all the properties of the entity (not including navigation properties). If a property is not included, the value is reset on the server to the default value for the property. This behavior for PUT requests maps to that described in the AtomPub RFC 5023. Example 13 shows the payload used to update the category that was inserted in the previous insert example. Since not all the properties are included in the payload, those not specified will be reset to their default values by the data service.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

桃气十足 2024-08-14 02:50:34

在 ADO.NET 数据服务服务器中,我们将 WriteMerge 定义为更改实体的各个属性。
(一个示例是更改员工实例的名字。)
WriteReplace 是将一个实体替换为另一个实体。
(一个示例是通过将实体的所有属性重置为默认值,然后显式设置属性来更改员工。)

使用 WriteMerge ,您可以将带有 MERGE 谓词的请求发送到实体的端点,
使用 WriteReplace ,您可以将带有 PUT 动词的请求发送到实体的端点。

希望这有帮助。

In the ADO.NET Data Services server, we define WriteMerge as changing individual properties of an entity.
(An example is Changing the FirstName of an Employee Instance.)
And WriteReplace as replacing an entity with another entity .
( An example is Changing an Employee by resetting all of the Entity's properties to defaults and then set the properties explicitly .)

With WriteMerge , you can send a request with the MERGE verb to an Entity's endpoint ,
with WriteReplace , you can send a request with the PUT verb to an Entity's endpoint .

Hope this helps.

离笑几人歌 2024-08-14 02:50:34

允许基于 WriteMerge-Merge 的更新。
允许 WriteReplace-替换

请查看此链接。
http://msdn.microsoft.com/en-us/magazine/dd569758。 aspx链接文本

WriteMerge-Merge-based updates are permitted.
WriteReplace-Replacing is permitted

Please take a look at this link.
http://msdn.microsoft.com/en-us/magazine/dd569758.aspxlink text

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文