Creating MAP from SOQL Query
Please use below syntax to get Map from SOQL.
Map<ID, Contact> contactIdMap= new Map<ID, Contact>([SELECT Id, LastName FROM Contact]);
Returns a set that contains all the keys in the map.
Set <Id> listOfIds = contactIdMap.ketSet();
Returns a list that contains all the values in the map.
List<Contact> contactList = contactIdMap.Values();
I hope this will help you.
Reference URL
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_map_sobject.htm
Map<ID, Contact> contactIdMap= new Map<ID, Contact>([SELECT Id, LastName FROM Contact]);
Returns a set that contains all the keys in the map.
Set <Id> listOfIds = contactIdMap.ketSet();
Returns a list that contains all the values in the map.
List<Contact> contactList = contactIdMap.Values();
I hope this will help you.
Reference URL
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_map_sobject.htm
Comments
Post a Comment