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
Baz DensonBaz Denson 

soql query of custom object and related object

I have a BRP_dealer__c object, and a dealer_productline__c related object.

I would like to pull all dealers and the product lines they hold into a list and serialize it into JSON.

I am currently trying this
list<BRP_Dealer__c> dealerList =  [SELECT id, 
                                                city__c,
                                                CompanyName__c,
                                                Country__c,
                                                Email__c,
                                                Fax__c,
                                                LineTwo__c,
                                                PartyID__c,
                                                PersonName__c,
                                                postcode__c,
                                                state__c,
                                                Street__c,
                                                Telephone__c,
                                                TypeCode__c,
                                                Website__c,
                                                (select Id, name, brp_dealer__c from Dealer_ProductLine__r)
                                                FROM BRP_Dealer__c];

But it doesnt work. How do I formulate this query?

Thanks

​​​​​​​
Best Answer chosen by Baz Denson
Baz DensonBaz Denson
I have resolved this now, my related object was dealer_productlines__r not dealer_productline__r
 

All Answers

GovindarajGovindaraj
Hi Baz,

What difficulty are you facing while running this query ?

Thanks,
Govindaraj.S
Baz DensonBaz Denson
I have resolved this now, my related object was dealer_productlines__r not dealer_productline__r
 
This was selected as the best answer