I'm fetching Contact
and Account
entities and I wish to access the name of the contact and the name of the primary contact. While the first one is accessed very easily by
EntityCollection result = proxy.RetrieveMultiple(...);
Entity entity = result.Entities[0].Attributes["fullname"];
the other seems to fight me throwing an exception. As far I can see, it depends on the fetch XML that has attributes for the name directly in <entity>
in the former case and under <entity><link-entity>
in the latter.
How can I access the field fullname
that is a linked entity?
Fetch XML for contacts:
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
<entity name='contact'>
<attribute name='fullname' />
</entity>
</fetch>
Fetch XML for accounts' primary contacts:
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
<entity name='account'>
<attribute name='accountid'/>
<link-entity name='listmember' from='entityid' to='accountid' visible='false' intersect='true'>
<link-entity name='list' from='listid' to='listid' alias='ab'>
</link-entity>
</link-entity>
<link-entity name='contact' from='contactid' to='primarycontactid' visible='false' link-type='outer' alias='...'>
<attribute name='fullname'/>
</link-entity>
</entity>
</fetch>