Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Map<id,list<contact>> accountRelatedContacts = new Map<id,list<contact>>(); for(Account acc : [select id,(select id from contacts) from Account]){ if(accountRelatedContacts.get(acc.id)==null) accountRelatedContacts.put(acc.id,new list<contact>{}); if(accountRelatedContacts.get(acc.id)!=null) accountRelatedContacts.get(acc.id).addAll(acc.contacts); }
load map as following