Using the RetrieveMultiple Method in Microsoft Dynamics CRM 4.0

// Set up the CRM Service.

CrmAuthenticationToken token = new


// You can use enums.cs from the SDK\Helpers folder to get

the enumeration for AD Authentication.

token.AuthenticationType = 0;

token.OrganizationName =”AdventureWorksCycle”;

CrmService service = new CrmService();




service.CrmAuthenticationTokenValue = token;

service.Credentials =


// Create the ColumnSet indicating the properties to be


ColumnSet cols = new ColumnSet();

// Sets the ColumnSet’s Properties

cols.Attributes = new string [] {“fullname”, “contactid”};

// Create the ConditionExpression

ConditionExpression condition = new ConditionExpression();

// Set the Condition for the Retrieval to be when the

contact’s address’ city is Sammamish

condition.AttributeName =”address1_city”;

condition.Operator = ConditionOperator.Like;

condition.Values = new string [] {“Sammamish”};

// Create the FilterExpression

FilterExpression filter = new FilterExpression();

// Set the Filter’s Properties

filter.FilterOperator = LogicalOperator.And;

filter.Conditions = new ConditionExpression[] {condition};

// Create the QueryExpression Object

QueryExpression query = new QueryExpression();

// Set the QueryExpression Object’s Properties

query.EntityName =;

query.ColumnSet = cols;

query.Criteria = filter;

// Retrieve the Contacts

BusinessEntityCollection contacts =



Author: Arvind Singh

Solution Architect with 15+ years of exp. Dynamics CRM, Power Platform, Azure which includes Solution, Design, Development, Deployment, Maintenance and support experience.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: