Skip to content

Instantly share code, notes, and snippets.

@xgeek-net
Last active March 17, 2017 07:04
Show Gist options
  • Save xgeek-net/b1ca85867f3b97846fa0e538fa88ae01 to your computer and use it in GitHub Desktop.
Save xgeek-net/b1ca85867f3b97846fa0e538fa88ae01 to your computer and use it in GitHub Desktop.
sObject List to Map
List<Account> accountList = [SELECT Id, Name FROM Account LIMIT 10];
Map<Id, Account> accountMap = new Map<Id, Account>();
if(accountList != null && !accountList.isEmpty()){
for(Account acc : accountList){
accountMap.put(acc.Id, acc);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment