function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Blake17Blake17 

Parsing relationship query results in C#

I am performing a simple child-to-parent relationship query between a custom child object (Packaged_Plan__c) and standard parent object (Opportunity):
 
    select Name, Opportunity__r.Name
    from Packaged_Plan__c
    where Opportunity__r.Name = 'abcxyz'
 
I am able to access the packaged plan fields by creating an object in C#:
 
    QueryResult qr = _binding.query(queryString);
    Packaged_Plan__c pp = (Packaged_Plan__c)qr.records[index];
    string ppName = pp.Name;
 
Since the opportunity name isn't contained in the custom packaged plan object, can someone please tell me know to access this value from the query results? The API documentation is minimal. I can perform another query if need be, but would rather do everything in one shot, if possible.
 
Also, does anyone know if it's possible to include an additional parent object in the query above (say, Account) and retrieve its values in the same query as well? E.g.,
 
    select Name, Account__r.Name, Opportunity__r.Name
    from Packaged_Plan__c
    where Opportunity__r.Name = 'abcxyz'
 
Thanks,
Blake
SuperfellSuperfell
String oppName = pp.Opportunity__r.Name;

And yes, you can query multiple parent relationships in a single query.
Blake17Blake17

Great! That worked and was really straightforward. Thanks for the quick response, Simon.

Blake