RetrieveMultipleRequest Class

Applies To: Microsoft Dynamics CRM 2013, Microsoft Dynamics CRM Online

Contains the data that is needed to retrieve a collection of records that satisfy the specified query criteria.

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

Syntax

'Declaration
<DataContractAttribute(Namespace:="https://schemas.microsoft.com/xrm/2011/Contracts")> _
Public NotInheritable Class RetrieveMultipleRequest
    Inherits OrganizationRequest
[DataContractAttribute(Namespace="https://schemas.microsoft.com/xrm/2011/Contracts")] 
public sealed class RetrieveMultipleRequest : OrganizationRequest

Example

The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface. For the complete sample, see the link later in this topic.

#region Retrieve records from an intersect table via QueryExpression

//Create Query Expression.
QueryExpression query = new QueryExpression()
{
    EntityName = "role",
    ColumnSet = new ColumnSet("name"),
    LinkEntities = 
    {
        new LinkEntity
        {
            LinkFromEntityName = Role.EntityLogicalName,
            LinkFromAttributeName = "roleid",
            LinkToEntityName = SystemUserRoles.EntityLogicalName,
            LinkToAttributeName = "roleid",
            LinkCriteria = new FilterExpression
            {
                FilterOperator = LogicalOperator.And,
                Conditions = 
                {
                    new ConditionExpression
                    {
                        AttributeName = "systemuserid",
                        Operator = ConditionOperator.Equal,
                        Values = { _userId }
                    }
                }
            }
        }
    }
};

// Obtain results from the query expression.
EntityCollection ec = _serviceProxy.RetrieveMultiple(query);

// Display results.
for (int i = 0; i < ec.Entities.Count; i++)
{
    Console.WriteLine("Query Expression Retrieved: {0}", ((Role)ec.Entities[i]).Name);
}

#endregion
'                    #Region "Retrieve records from an intersect table via QueryExpression"

'Create Query Expression.
Dim query As New QueryExpression() With
    {
        .EntityName = "role",
        .ColumnSet = New ColumnSet("name")
    }

Dim queryLinkEntity As New LinkEntity With
    {
        .LinkToEntityName = SystemUserRoles.EntityLogicalName,
        .LinkFromAttributeName = "roleid",
        .LinkToAttributeName = "roleid"
    }
queryLinkEntity.LinkCriteria().AddCondition(
    "systemuserid",
    ConditionOperator.Equal,
    _userId)
queryLinkEntity.LinkCriteria().FilterOperator = LogicalOperator.And
query.LinkEntities().Add(queryLinkEntity)

' Obtain results from the query expression.
Dim ec As EntityCollection = _serviceProxy.RetrieveMultiple(query)

' Display results.
For i As Integer = 0 To ec.Entities.Count - 1
    Console.WriteLine("Query Expression Retrieved: {0}",
                      (CType(ec.Entities(i), Role)).Name)
Next i

'                    #End Region

Remarks

Message Availability

This message works regardless whether the caller is connected to the server or offline. However, a few entities of this message class are exceptions to that availability. To determine which entities have a more restricted availability, see Supported Entities later in this topic.

Usage

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

Privileges and Access Rights

To perform this action, the caller must have privileges on the specified entities in the Query property and read access rights on the records that are returned from the query. For a list of the required privileges, see RetrieveMultiple Privileges.

Notes for Callers

This message supports queries that use Query Expression and FetchXML. For more information, see Creating Queries to Retrieve Data. You can also use the RetrieveMultiple method.

The collection of returned records from this message contains only the records for which the caller has read access. The returned records contain values for specified properties in the ColumnSet parameter that are valid for retrieval and for which the calling user has access rights. Any other property values are not returned. For more information about field security, see How Field Security Can Be Used to Control Access to Field Values In CRM.

Supported Entities

You can use this method to retrieve any records for entities that support the RetrieveMultiple message, including custom entities.

The following table shows the default entities that support this message. For the listed entities of this message, the Availability column shows Server if the caller must be connected to the server and shows Both if the caller can be either connected to, or disconnected from, the server.

Entity Availability

account

Both

accountleads

Both

activitymimeattachment

Both

activityparty

Both

activitypointer

Both

annotation

Both

annualfiscalcalendar

Both

appointment

Both

asyncoperation

Both

attributemap

Server

audit

Server

bulkdeletefailure

Both

bulkdeleteoperation

Both

bulkoperation

Both

bulkoperationlog

Both

businessunit

Both

businessunitnewsarticle

Both

calendar

Both

campaign

Both

campaignactivity

Both

campaignactivityitem

Both

campaignitem

Both

campaignresponse

Both

columnmapping

Both

competitor

Both

competitorproduct

Both

competitorsalesliterature

Both

connection

Both

connectionrole

Both

connectionroleassociation

Both

connectionroleobjecttypecode

Both

constraintbasedgroup

Both

contact

Both

contactinvoices

Both

contactleads

Both

contactorders

Both

contactquotes

Both

contract

Both

contractdetail

Both

contracttemplate

Both

customeraddress

Both

customeropportunityrole

Both

customerrelationship

Both

dependency

Server

discount

Both

discounttype

Both

displaystring

Both

duplicaterecord

Server

duplicaterule

Server

duplicaterulecondition

Both

email

Both

emailserverprofile

Server

entitymap

Server

equipment

Both

fax

Both

fieldpermission

Server

fieldsecurityprofile

Server

fixedmonthlyfiscalcalendar

Both

goal

Both

goalrollupquery

Both

import

Both

importentitymapping

Both

importfile

Both

importjob

Both

importlog

Both

importmap

Both

incident

Both

incidentresolution

Both

invaliddependency

Server

invoice

Both

invoicedetail

Both

isvconfig

Both

kbarticle

Both

kbarticlecomment

Both

kbarticletemplate

Both

lead

Both

leadaddress

Both

leadcompetitors

Both

leadproduct

Both

letter

Both

license

Both

list

Both

listmember

Both

lookupmapping

Both

mailbox

Both

mailmergetemplate

Both

metric

Both

monthlyfiscalcalendar

Both

msdyn_postalbum

Server

msdyn_postconfig

Server

msdyn_postruleconfig

Server

opportunity

Both

opportunityclose

Both

opportunitycompetitors

Both

opportunityproduct

Both

orderclose

Both

organization

Both

organizationui

Both

ownermapping

Both

phonecall

Both

picklistmapping

Both

pluginassembly

Both

plugintype

Both

plugintypestatistic

Server

post

Server

postcomment

Server

postfollow

Server

postlike

Server

pricelevel

Both

principalobjectattributeaccess

Both

privilege

Both

processsession

Both

product

Both

productassociation

Both

productpricelevel

Both

productsalesliterature

Both

productsubstitute

Both

publisher

Both

publisheraddress

Server

quarterlyfiscalcalendar

Both

queue

Both

queueitem

Both

quote

Both

quoteclose

Both

quotedetail

Both

recurrencerule

Both

recurringappointmentmaster

Both

relationshiprole

Both

relationshiprolemap

Both

report

Both

reportcategory

Both

reportentity

Both

reportlink

Both

reportvisibility

Both

resource

Both

resourcegroup

Both

resourcespec

Both

role

Both

roleprivileges

Both

rollupfield

Both

salesliterature

Both

salesliteratureitem

Both

salesorder

Both

salesorderdetail

Both

savedquery

Both

savedqueryvisualization

Both

sdkmessage

Both

sdkmessagefilter

Both

sdkmessagepair

Both

sdkmessageprocessingstep

Both

sdkmessageprocessingstepimage

Both

sdkmessageprocessingstepsecureconfig

Server

sdkmessagerequest

Both

sdkmessagerequestfield

Both

sdkmessageresponse

Both

sdkmessageresponsefield

Both

semiannualfiscalcalendar

Both

service

Both

serviceappointment

Both

servicecontractcontacts

Both

serviceendpoint

Server

sharepointdocumentlocation

Server

sharepointsite

Server

site

Both

sitemap

Both

solution

Both

solutioncomponent

Both

subject

Both

systemform

Both

systemuser

Both

systemuserlicenses

Both

systemuserprofiles

Server

systemuserroles

Both

task

Both

team

Both

teammembership

Both

teamprofiles

Server

teamroles

Both

template

Both

territory

Both

timezonedefinition

Both

timezonelocalizedname

Both

timezonerule

Both

tracelog

Both

transactioncurrency

Both

transformationmapping

Both

transformationparametermapping

Both

uom

Both

uomschedule

Both

userentityinstancedata

Both

userentityuisettings

Both

userform

Both

userquery

Both

userqueryvisualization

Both

usersettings

Both

webresource

Both

workflow

Server

workflowdependency

Server

workflowlog

Server

Inheritance Hierarchy

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

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.

Platforms

Development Platforms

Windows Server 2008, Windows Server 2012, Windows 7 (All Versions), Windows 8 (All Versions)

Target Platforms

Windows Server 2008, ,Windows Server 2012, ,Windows 7 (All Versions),

Change History

See Also

Reference

RetrieveMultipleRequest Members
Microsoft.Xrm.Sdk.Messages Namespace
RetrieveMultipleResponse

Other Resources

Create Queries to Retrieve Data
Build Queries with QueryExpression
Build Queries with FetchXML
Retrieve Records for Many-To-Many Relationships using Intersect Entities
Sample: Retrieve Records from an Intersect Table

Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.