Partilhar via


UpdateMultipleRequest Class

Definition

Contains the data to update multiple records of the same type with a single web request.

[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class UpdateMultipleRequest : Microsoft.Xrm.Sdk.OrganizationRequest
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")>]
type UpdateMultipleRequest = class
    inherit OrganizationRequest
Public NotInheritable Class UpdateMultipleRequest
Inherits OrganizationRequest
Inheritance
UpdateMultipleRequest
Attributes

Examples

The following example shows how to use the UpdateMultiple message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService instance.

/// <summary>
/// Demonstrates the use of the UpdateMultiple message.
/// </summary>
/// <param name="service">The authenticated IOrganizationService instance.</param>
/// <param name="recordsToUpdate">A list of records to create.</param>
static void UpdateMultipleExample(IOrganizationService service, List<Entity> recordsToUpdate) {
    // Create an EntityCollection populated with the list of entities.
    EntityCollection entities = new(recordsToUpdate)
    {
        // All the records must be for the same table.
        EntityName = recordsToUpdate[0].LogicalName
    };

    // Use UpdateMultipleRequest
    UpdateMultipleRequest updateMultipleRequest = new()
    {
        Targets = entities,
    };

    service.Execute(updateMultipleRequest);
}

Sample code on GitHub

Create and Update Multiple Sample

Remarks

Pass an instance of this class to the Execute(OrganizationRequest) method, which returns an instance of the UpdateMultipleResponse class.

It will work for all elastic tables, but only for those standard tables that have enabled this message. You can use the following static IsMessageAvailable method to determine whether a standard table supports the UpdateMultiple message. Set the table logical name as the entityLogicalName parameter and UpdateMultiple as the messageName parameter.

/// <summary>
/// Detect whether a specified message is supported for the specified table.
/// </summary>
/// <param name="service">The IOrganizationService instance.</param>
/// <param name="entityLogicalName">The logical name of the table.</param>
/// <param name="messageName">The name of the message.</param>
/// <returns></returns>
public static bool IsMessageAvailable(
    IOrganizationService service,
    string entityLogicalName,
    string messageName)
{
    QueryExpression query = new("sdkmessagefilter")
    {
        ColumnSet = new ColumnSet("sdkmessagefilterid"),
        Criteria = new FilterExpression(LogicalOperator.And)
        {
            Conditions = {
    new ConditionExpression(
        attributeName:"primaryobjecttypecode",
        conditionOperator: ConditionOperator.Equal,
        value: entityLogicalName)
    }
        },
        LinkEntities = {
            new LinkEntity(
                linkFromEntityName:"sdkmessagefilter",
                linkToEntityName:"sdkmessage",
                linkFromAttributeName:"sdkmessageid",
                linkToAttributeName:"sdkmessageid",
                joinOperator: JoinOperator.Inner)
            {
                    LinkCriteria = new FilterExpression(LogicalOperator.And){
                    Conditions = {
                        new ConditionExpression(
                            attributeName:"name",
                            conditionOperator: ConditionOperator.Equal,
                            value: messageName)
                        }
                    }
            }
        }
    };

    EntityCollection entityCollection = service.RetrieveMultiple(query);

    return entityCollection.Entities.Count.Equals(1);
}

For more information see: Bulk Operation messages.

Constructors

UpdateMultipleRequest()

Initializes a new instance of the UpdateMultipleRequest class.

Properties

ConcurrencyBehavior

Specifies the type of optimistic concurrency behavior that should be performed by Dataverse when processing this request.

ExtensionData

Gets or sets the structure that contains extra data. Optional.

(Inherited from OrganizationRequest)
Item[String]

Gets or sets the indexer for the Parameters collection.

(Inherited from OrganizationRequest)
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 update.

Applies to