IOrganizationService correct way to update entities

拟墨画扇 提交于 2019-12-06 15:40:36

First of all both Update and Execute of an UpdateRequest produce the same result.

The main difference is that an UpdateRequest can be batched using the ExecuteMultipleRequest

With the CreateRequest as well as the UpdateRequest you can switch duplicate detection, as in the following example:

public Guid CreateTest(Entity account, IOrganizationService service)
{
    var request = new CreateRequest { Target = account };
    request.Parameters.Add("SuppressDuplicateDetection", false);
    var response = service.Execute(request) as CreateResponse;
    return response.id;
}

You cannot do this using the Create and Update methods.

And, of course, you can feed Request objects to the ExecuteMultipleRequest to throttle the number of roundtrips to the OrganizationService.

I expect the Create and Update methods to be slightly more efficient, but I doubt if it would be measurable.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!