• irfan alam
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi,

Can someone help me in understanding the difference between below mentioned two statements. You can see that its the same SOQL query being used in both the statements. But it's the collection to store the SOQL results that differs. How does List and Map behave in these two statements?

List<Account> acctsWithOpps = [SELECT Id,(SELECT Id,Name FROM Opportunities) FROM Account WHERE Id IN :Trigger.New];

AND

Map<Id, Account> AcctWithOpps = new Map<Id, Account>([SELECT Id,(SELECT Id FROM Opportunities) FROM Account WHERE ID IN:Trigger.New]);

Thanks & Regards,
B Archana