I am passing a list of opportunities (opplist) to a method. For each opportuntiy, I have to check the description field of its related account. And based on that field, I will add the respective list of opportunities to another opportunity lists. If description is 'Yes' then to 'yeslist, and if 'No' then to 'nolist'. In the method receiving the opplist, I added the below code.
public static List<Opportunities> samplemethod(List<Opportunity> opplist){
Set<Id> opptIds = (new Map<Id,SObject>(opplist)).keySet();
List<Opportunity> opp = [Select o.Id, o.AccountId, o.Account.Description from opportunity o where Id IN :opptIds] ;
Map<sObject,sObject> OppMap = new Map<sObject,sObject>(opplist,opp);
Basically I want to map the opplist with the list having the description field for same corresponding IDs (Same record. opplist has original record passed to method and opp has record with description field .
My doubt is is there a way to keep sobject as both key and value pair in maps ? I am planing to iterate the map over for loop after this.