开发者

What is the difference between WriteReplace & WriteMerge in ADO.NET DataService?

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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜