Monday 22 September 2014

You can store child records with related parent Id into the list

First create the list and store the child and parent records into the list .

list<Parent> lstParent = new list<Parent>();

for(Parent objParent :[select Id,Name,(select Name from child__r order by Name)
                                                                                                       from Parent order by Name])
{
lstParent.add(objParent);
}

you can fetch the child values from the list


system.debug('-----------child.Name'lstParent.get(0).child__r);

try to use this on the developer console.

No comments:

Post a Comment