Getting child objects of Master object in salesforce

Sample code:
 
Schema.DescribeSObjectResult R = Account.SObjectType.getDescribe();
List<Schema.ChildRelationship> C = R.getChildRelationships();

for (Schema.ChildRelationship cr: C) 
{
relName.add(cr.getRelationshipName());
}
 
Query:
 
SELECT Name,(Select Name,AccountId From Contacts) FROM Account 


Cheers!!!

No comments:

Post a Comment