Message SDK | Description | Exemples |
ExecuteMultipleRequest | Exécute une ou plusieurs requêtes comme une simple demande | cs vb |
Exemple en C#
ExecuteMultipleRequest requestWithResults = new ExecuteMultipleRequest() { // Assign settings that define execution behavior: continue on error, return responses. Settings = new ExecuteMultipleSettings() { ContinueOnError = false, ReturnResponses = true }, // Create an empty organization request collection. Requests = new OrganizationRequestCollection() }; // Create several (local, in memory) entities in a collection. EntityCollection input = GetCollectionOfEntitiesToCreate(); // Add a CreateRequest for each entity to the request collection. foreach (var entity in input.Entities) { CreateRequest createRequest = new CreateRequest { Target = entity }; requestWithResults.Requests.Add(createRequest); } // Execute all the requests in the request collection using a single web method call. ExecuteMultipleResponse responseWithResults = (ExecuteMultipleResponse)_serviceProxy.Execute(requestWithResults); // Display the results returned in the responses. foreach (var responseItem in responseWithResults.Responses) { // A valid response. if (responseItem.Response != null) DisplayResponse(requestWithResults.Requests[responseItem.RequestIndex], responseItem.Response); // An error has occurred. else if (responseItem.Fault != null) DisplayFault(responseItem.Fault); }
Aucun commentaire:
Enregistrer un commentaire