Example: Retrieve All contact records where MobilePhone data is not null.
public EntityCollection RetrieveAllContactEntityRecords(IOrganizationService _service) { // Declarations var contactFinalEntityCollection = new EntityCollection(); EntityCollection contactEntityCollection = new EntityCollection(); int pageNumber = 1; bool moreRecords = true; // Retrive Contact Records using CRM Paging. while (moreRecords) { var queryExpression = new QueryExpression() { Distinct = false, EntityName = "contact", ColumnSet = new ColumnSet(true), Criteria = new FilterExpression { FilterOperator = LogicalOperator.And, Conditions = { new ConditionExpression("mobilephone", ConditionOperator.NotNull) } }, Orders = { new OrderExpression { AttributeName = "createdon", OrderType = OrderType.Descending } }, PageInfo = { Count = 5000, PagingCookie = (pageNumber == 1) ? null : contactEntityCollection.PagingCookie, PageNumber = pageNumber++ } }; contactEntityCollection = _service.RetrieveMultiple(queryExpression); if (contactEntityCollection.Entities.Count > 0) { contactFinalEntityCollection.Entities.AddRange(contactEntityCollection.Entities); } moreRecords = contactEntityCollection.MoreRecords; } return contactFinalEntityCollection; }