I've noticed that when using parent to child SOQL query we mark the receiving variables as if they will receive a single record but these variables will in fact receive a list of record.
as you could see below:
for(Account MyAccountList : [select id, (select id from contacts) from account where id in :accountIds])
{
for(Contact MyContactList : MyAccountList.contacts)
{
......
}
}
Is there a reason I don't understand for doing this?
MyAccountList
is an inappropriate variable name here, it should bemyAccount
. The child relationship query always return a list. It would be nice if you could reframe your question and make more clear.