Created
September 5, 2013 03:42
-
-
Save ashramsey/6445826 to your computer and use it in GitHub Desktop.
Creates a connection to the CRM, and retrieves all account records (Organisations) from the CRM. I'm guessing, one of the columns is no longer valid??
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Entity> GetOrganizations() | |
{ | |
List<Entity> accounts = null; | |
// Establish a connection to the organization web service using CrmConnection. | |
Microsoft.Xrm.Client.CrmConnection connection = CrmConnection.Parse(this.ConnectionString); | |
using (_orgService = new OrganizationService(connection)) | |
{ | |
// Retrieve the several attributes from the new account. | |
QueryExpression query = new QueryExpression(); | |
query.EntityName = "account"; | |
query.ColumnSet = new ColumnSet(true); | |
query.LinkEntities.Add(new LinkEntity("account", "contact", "primarycontactid", "contactid", JoinOperator.LeftOuter)); | |
query.LinkEntities[0].Columns.AddColumns("firstname", "lastname"); | |
query.LinkEntities[0].EntityAlias = "primarycontact"; | |
accounts = _orgService.RetrieveMultiple(query).Entities.ToList(); | |
} | |
return accounts; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment