Here's an example showing how to bundle multiple UpsertRequests into one ExecuteMultipleRequest:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var entityCollection; // your EntityCollection | |
var requests = new ExecuteMultipleRequest(); | |
foreach (var entity in entityCollection.Entities) { | |
var upsertRequest = new UpsertRequest { Target = entity }; | |
requests.Requests.Add(upsertRequest); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var responses = service.Execute(requests); | |
var errors = new List<Entity>(); | |
foreach (var response in responses.Responses) { | |
if (response.Fault) { | |
var entity = entityCollection[response.RequestIndex]; | |
errors.Add(entity); | |
} | |
} |
- response.RequestIndex is used to aaccess the response's corresponding request by matching their indexes.
- responses.Responses contains a collection of ExecuteMultipleResponseItems.
No comments:
Post a Comment