Execute Multiple

The ExecuteMultiple method allows for multiple Entity objects to be created using the generic CreateCommand class and to update multiple Entity objects using the UpdateCommand class.

However, recommended best practice is to use entity specific create commands for creation of entity objects and entity specific update commands for updating entities if available.

Update Multiple Entities - Entity Specific Update

Example: Re-Open multiple Work Orders using the WoReopenCommand.

var results = ExecuteMultiple( 
  new[] 
  {
    new WoReopenCommand {WorkOrderId = workOrderId1},
    new WoReopenCommand {WorkOrderId = workOrderId2},
    new WoReopenCommand {WorkOrderId = workOrderId3},
    new WoReopenCommand {WorkOrderId = workOrderId4} 
  } 
);

Create Multiple Entities - Entity Specific Create

Example: Pause multiple Work Orders using the WoPauseCommand.

var results = ExecuteMultiple( 
  new[] 
  {
    new WoPauseCommand {WorkOrderId = workOrderId1},
    new WoPauseCommand {WorkOrderId = workOrderId2},
    new WoPauseCommand {WorkOrderId = workOrderId3},
    new WoPauseCommand {WorkOrderId = workOrderId4}
  } 
);

Create Multiple Entities

Example: Create multiple Specialties using the CreateCommand.

var results = corrigoService.ExecuteMultiple( 
  new[] 
  {
    new CreateCommand {Entity = new Specialty {DisplayAs = specialty1}},
    new CreateCommand {Entity = new Specialty {DisplayAs = specialty2}},
    new CreateCommand {Entity = new Specialty {DisplayAs = specialty3}},
    new CreateCommand {Entity = new Specialty {DisplayAs = specialty4}}
  } 
);

Update Multiple Entities

Example: Update the instructions for multiple Specialties using the UpdateCommand.

var results = corrigoService.ExecuteMultiple( 
 new[] 
 {
  new UpdateCommand {Entity = new Specialty {Id = id1, Instructions = instructions1}},
  new UpdateCommand {Entity = new Specialty {Id = id2, Instructions = instructions2}},
  new UpdateCommand {Entity = new Specialty {Id = id3, Instructions = instructions3}},
  new UpdateCommand {Entity = new Specialty {Id = id4, Instruction s= instructions4}},
 } 
);