Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
Bob Smith asked in #Apex
Can't we delete Records by using Map Collection Type....?

Map<Id, Account> m = new Map<Id,Account>([Select id from Account Limit 3]);

delete m;

How to achieve by using Map?

 
1 answer
  1. Apr 7, 2015, 8:15 AM
    You can't use a map, but you can simply pass the values list from the map as follows:

     

    Map<Id, Account> m = new Map<Id,Account>([Select id from Account Limit 3]);

    delete m.values();

     
0/9000