UpsertMultipleRequest Class  
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Contains the data to create or update multiple records of the same type in a single request.
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class UpsertMultipleRequest : Microsoft.Xrm.Sdk.OrganizationRequest[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")>]
type UpsertMultipleRequest = class
    inherit OrganizationRequestPublic NotInheritable Class UpsertMultipleRequest
Inherits OrganizationRequest- Inheritance
- Attributes
Examples
         The following example shows how to use the UpsertMultiple message. 
         For this sample to work correctly, you must be connected to the server to get an 
IOrganizationService instance.
         This static UpsertMultipleExample method depends on a samples_bankaccounttable that has a string column named 
samples_accountname configured as an alternate key. 
         It also has a string column named samples_description. 
         This code uses the 
Entity constructor that sets the keyName and keyValue
         to specify the alternate key value.
/// <summary>
/// Demonstrates using UpsertMultiple with alternate key values
/// </summary>
/// <param name="service">The authenticated IOrganizationService instance</param>
static void UpsertMultipleExample(IOrganizationService service)
{
      var tableLogicalName = "samples_bankaccount";
      // samples_accountname string column is configued as an alternate key
      // for the samples_bankaccount table
      var altKeyColumnLogicalName = "samples_accountname";
      // Create one record to update with upsert
      service.Create(new Entity(tableLogicalName)
      {
         Attributes =
         {
            {altKeyColumnLogicalName, "Record For Update"},
            {"samples_description","A record to update using Upsert" }
         }
      });
      // Using the Entity constructor to specify alternate key
      Entity toUpdate = new(
            entityName: tableLogicalName,
            keyName: altKeyColumnLogicalName,
            // Same alternate key value as created record.
            keyValue: "Record For Update");
      toUpdate["samples_description"] = "Updated using Upsert";
      Entity toCreate = new(
         entityName: tableLogicalName,
         keyName: altKeyColumnLogicalName,
         keyValue: "Record For Create");
      toCreate["samples_description"] = "A record to create using Upsert";
      // Add the records to a collection
      EntityCollection records = new()
      {
         EntityName = tableLogicalName,
         Entities = { toUpdate, toCreate }
      };
      // Send the request
      UpsertMultipleRequest request = new()
      {
         Targets = records
      };
      var response = (UpsertMultipleResponse)service.Execute(request);
      // Process the responses:
      foreach (UpsertResponse item in response.Results)
      {
         Console.WriteLine($"Record {(item.RecordCreated ? "Created" : "Updated")}");
      }
}
Output:
Record Updated
Record Created
For sample code on GitHub, see the UpsertMultiple project in the Bulk Operations Sample solution.
Remarks
Usage
Pass an instance of this class to the Execute(OrganizationRequest) method, which returns an instance of the UpsertMultipleResponse class.
Privileges and Access Rights
To perform this action, the caller must have privileges on the table for the Entity set to the Targets property. Generally, callers must have Read and Write privileges for the table. Learn more about how to verify access in code
Notes for Callers
For more information, see:
Supported tables
UpsertMultiple is available for any table that supports CreateMultiple and UpdateMultiple messages. Learn how to check availablity for the CreateMultiple and UpdateMultiple messages.
Constructors
| UpsertMultipleRequest() | Initializes a new instance of the UpsertMultipleRequest class. | 
Properties
| ExtensionData | Gets or sets the structure that contains extra data. Optional.(Inherited from OrganizationRequest) | 
| Item[String] | Gets or sets the indexer for the  | 
| Parameters | Gets or sets the collection of parameters for the request. Required, but is supplied by derived classes.(Inherited from OrganizationRequest) | 
| RequestId | Gets or sets the ID of the request. Optional.(Inherited from OrganizationRequest) | 
| RequestName | Gets or sets the name of the request. Required, but is supplied by derived classes.(Inherited from OrganizationRequest) | 
| Targets | Gets or sets the collection of entities representing records to create or update. |