IOrganizationService the correct way to update objects

I am looking at the best way to update / retrieve objects from C #. I read the MSDN documentation but don't know where to go / when to use any method.

So my question is:

Should I use:

  • IOrganizationService.Update() and update the object directly; or
  • IOrganization.Execute() and create an update request

    And if the answer depends, what situation justifies which method?

thanks

+1
source share
2 answers

First of all, Update and Run UpdateRequest give the same result.

The main difference is that UpdateRequest can be unloaded using ExecuteMultipleRequest

+4
source

With CreateRequest , as well as UpdateRequest you can switch re-discovery, as shown 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 with the Create and Update methods.

And, of course, you can pass Request objects to ExecuteMultipleRequest to reduce the number of calls to the organization’s web service.

I expect the Create and Update methods to be somewhat more efficient, but I doubt it will be measurable.

+1
source

Source: https://habr.com/ru/post/982220/


All Articles