I have a SOQL query that pulls a list of accounts and associated contact records.
Is there a way to get the child contact records into a map without looping over the accounts and then looping over the contacts?
List<Account> accountsWithContacts = [SELECT ID, Name, (SELECT Id, Name FROM Contacts__r)
FROM Account];
Map<Id, Contact> contactMap = new Map<Id,Contact>();
If there are 7 contacts returned for a given Account I am trying to figure out the map syntax to extract just the child contacts into a map of of their own.