Jaa


ExecuteMultipleRequest Class

 

Applies To: Dynamics CRM 2015

Contains the data that is needed to execute one or more message requests as a single batch operation, and optionally return a collection of results.

Namespace:   Microsoft.Xrm.Sdk.Messages
Assembly:  Microsoft.Xrm.Sdk (in Microsoft.Xrm.Sdk.dll)

Inheritance Hierarchy

System.Object
  Microsoft.Xrm.Sdk.OrganizationRequest
    Microsoft.Xrm.Sdk.Messages.ExecuteMultipleRequest

Syntax

[DataContractAttribute(Namespace = "https://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class ExecuteMultipleRequest : OrganizationRequest
[DataContractAttribute(Namespace = "https://schemas.microsoft.com/xrm/2011/Contracts")]
public ref class ExecuteMultipleRequest sealed : OrganizationRequest
[<Sealed>]
[<DataContractAttribute(Namespace = "https://schemas.microsoft.com/xrm/2011/Contracts")>]
type ExecuteMultipleRequest = 
    class
        inherit OrganizationRequest
    end
<DataContractAttribute(Namespace := "https://schemas.microsoft.com/xrm/2011/Contracts")>
Public NotInheritable Class ExecuteMultipleRequest
    Inherits OrganizationRequest

Constructors

Name Description
System_CAPS_pubmethod ExecuteMultipleRequest()

Initializes a new instance of the ExecuteMultipleRequest.

Properties

Name Description
System_CAPS_pubproperty ExtensionData

Gets or sets the structure that contains extra data. Optional.(Inherited from OrganizationRequest.)

System_CAPS_pubproperty Item[String]

Gets or sets the indexer for the Parameters collection.(Inherited from OrganizationRequest.)

System_CAPS_pubproperty Parameters

Gets or sets the collection of parameters for the request. Required, but is supplied by derived classes.(Inherited from OrganizationRequest.)

System_CAPS_pubproperty RequestId

Gets or sets the ID of an asynchronous operation (system job). Optional. (Inherited from OrganizationRequest.)

System_CAPS_pubproperty RequestName

Gets or sets the name of the request. Required, but is supplied by derived classes.(Inherited from OrganizationRequest.)

System_CAPS_pubproperty Requests

Gets or sets the collection of message requests to execute.

System_CAPS_pubproperty Settings

Gets or sets the settings that define whether execution should continue if an error occurs and if responses for each message request processed are to be returned.

Methods

Name Description
System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_pubmethod ToString()

(Inherited from Object.)

Remarks

Message Availability

 This message works regardless whether the caller is connected to the server or offline.

Usage

Pass an instance of this class to the Execute method, which returns an instance of the ExecuteMultipleResponse class.

Privileges and Access Rights

There are no specific privileges required for this request. Refer to the required privileges and access rights of each message request you add to the Requests collection. Refer to Privileges by message.

Notes for Callers

CallerId is honored for each message request. See the related topics for throttling limitations.

Examples

The following sample shows how to execute the ExecuteMultipleRequest message.


// Get a reference to the organization service.
using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials))
{
    // Enable early-bound type support to add/update entity records required for this sample.
    _serviceProxy.EnableProxyTypes();

    #region Execute Multiple with Results
    // Create an ExecuteMultipleRequest object.
    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(requestWithResults.Requests[responseItem.RequestIndex], 
                responseItem.RequestIndex, responseItem.Fault);
    }

' Get a reference to the organization service.
_serviceProxy = ServerConnection.GetOrganizationProxy(serverConfig)

Using _serviceProxy
    ' Enable early-bound type support to add/update entity records required for this sample.
    _serviceProxy.EnableProxyTypes()

    '#Region "Execute Multiple with Results"
    ' Create an ExecuteMultipleRequest object.
    ' Assign settings that define execution behavior: continue on error, return responses.
    ' Create an empty organization request collection.
    requestWithResults = New ExecuteMultipleRequest() With
        {
            .Settings = New ExecuteMultipleSettings() With
                        {
                            .ContinueOnError = False,
                            .ReturnResponses = True
                        },
            .Requests = New OrganizationRequestCollection()
        }

    ' Create several (local, in memory) entities in a collection. 
    Dim input As EntityCollection = GetCollectionOfEntitiesToCreate()

    ' Add a CreateRequest for each entity to the request collection.
    For Each entity In input.Entities
        Dim createRequest_Renamed As CreateRequest = New CreateRequest With {.Target = entity}
        requestWithResults.Requests.Add(createRequest_Renamed)
    Next entity

    ' Execute all the requests in the request collection using a single web method call.
    Dim responseWithResults As ExecuteMultipleResponse =
        CType(_serviceProxy.Execute(requestWithResults), ExecuteMultipleResponse)

    ' Display the results returned in the responses.
    For Each responseItem In responseWithResults.Responses

        If responseItem.Response IsNot Nothing Then
            ' A valid response.
            DisplayResponse(requestWithResults.Requests(responseItem.RequestIndex),
                            responseItem.Response)

        ElseIf responseItem.Fault IsNot Nothing Then
            ' An error has occurred.
            DisplayFault(requestWithResults.Requests(responseItem.RequestIndex),
                         responseItem.RequestIndex, responseItem.Fault)
        End If
    Next responseItem

Thread Safety

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

ExecuteMultipleSettings
ExecuteMultiplePerOrgMaxConnectionsPerServer
ExecuteMultipleMaxConnectionsPerServer
Microsoft.Xrm.Sdk.Messages Namespace
Use messages (request and response classes) with the Execute method
Sample: Execute multiple requests

Return to top

© 2016 Microsoft. All rights reserved. Copyright