Wednesday, April 15, 2015

Retrieve AliasedValue form fetch xml


string fetchXML = string.Format(@"<fetch version='1.0' output-format='xml-platform' no-lock='true' mapping='logical'> <entity name='account'> <attribute name='name' /> <filter type='and'> <condition attribute='statuscode' operator='eq' value='1' /> <condition attribute='accountid' operator='eq' value='{0}' /> </filter> <link-entity name='contact' from='contactid' to='primarycontactid' alias='ab'> <attribute name='fullname' alias='as_fullname' /> <attribute name='firstname' alias='as_firstname' /> <attribute name='lastname' alias='as_lastname' /> </link-entity> </entity> </fetch>", accountId.ToString()); var fetchExp = new FetchExpression(fetchXML); EntityCollection accountEntity = orgService.RetrieveMultiple(fetchExp); if (accountEntity.Entities.Count > 0) { //Primary Contact Fullname AliasedValue avContactFullname = accountEntity.Entities[0].GetAttributeValue<AliasedValue>("as_fullname"); if (avContactFullname != null) contactFullName = avContactFullname.Value; //Primary Contact Firstname AliasedValue avContactFirstname = accountEntity.Entities[0].GetAttributeValue<AliasedValue>("as_firstname"); if (avContactFirstname != null) contactFirstName = avContactFirstname.Value; //Primary Contact Lastname AliasedValue avContactLastname = accountEntity.Entities[0].GetAttributeValue<AliasedValue>("as_lastname"); if (avContactLastname != null) contactLastName = avContactLastname.Value; }

No comments:

Post a Comment

Get files of last hour in Azure Data Factory

  Case I have a Data Factory pipeline that should run each hour and collect all new files added to the data lake since the last run. What is...