Skip to main content
edited body
Source Link
Return0
  • 317
  • 2
  • 8
  • 21

If i have a query like

Map<Id,TER_Meter__c> mapIdToMeterPair=new Map<Id,TER_Meter__c>([Select Id,Name,(Select PAS_Customer_Consent_Flag_Effective_From__c,PAS_Customer_Consent_Flag_Effective_To__c,PAS_Consent__c from Consents__r),PAS_MSID_Effective_From__c,PAS_MSID_Effective_To__c,TER_Accepted__c from TER_Meter__c where Id in:meterIds]); 

Currently key part of map is id type and contains id of record being fetched, in this case TER_Meter__c.

  • Is there any way we can change what gets stored in the key part of the map while fetching value directly from query orin to map.
  • If so is it also possible to store value from inner query to key part of map.

If i have a query like

Map<Id,TER_Meter__c> mapIdToMeterPair=new Map<Id,TER_Meter__c>([Select Id,Name,(Select PAS_Customer_Consent_Flag_Effective_From__c,PAS_Customer_Consent_Flag_Effective_To__c,PAS_Consent__c from Consents__r),PAS_MSID_Effective_From__c,PAS_MSID_Effective_To__c,TER_Accepted__c from TER_Meter__c where Id in:meterIds]); 

Currently key part of map is id type and contains id of record being fetched, in this case TER_Meter__c.

  • Is there any way we can change what gets stored in the key part of the map while fetching value directly from query or to map.
  • If so is it also possible to store value from inner query to key part of map.

If i have a query like

Map<Id,TER_Meter__c> mapIdToMeterPair=new Map<Id,TER_Meter__c>([Select Id,Name,(Select PAS_Customer_Consent_Flag_Effective_From__c,PAS_Customer_Consent_Flag_Effective_To__c,PAS_Consent__c from Consents__r),PAS_MSID_Effective_From__c,PAS_MSID_Effective_To__c,TER_Accepted__c from TER_Meter__c where Id in:meterIds]); 

Currently key part of map is id type and contains id of record being fetched, in this case TER_Meter__c.

  • Is there any way we can change what gets stored in the key part of the map while fetching value directly from query in to map.
  • If so is it also possible to store value from inner query to key part of map.
Source Link
Return0
  • 317
  • 2
  • 8
  • 21

Which element from Soql query gets stored in key part of MAP while fetching records from SOQL query directly in map

If i have a query like

Map<Id,TER_Meter__c> mapIdToMeterPair=new Map<Id,TER_Meter__c>([Select Id,Name,(Select PAS_Customer_Consent_Flag_Effective_From__c,PAS_Customer_Consent_Flag_Effective_To__c,PAS_Consent__c from Consents__r),PAS_MSID_Effective_From__c,PAS_MSID_Effective_To__c,TER_Accepted__c from TER_Meter__c where Id in:meterIds]); 

Currently key part of map is id type and contains id of record being fetched, in this case TER_Meter__c.

  • Is there any way we can change what gets stored in the key part of the map while fetching value directly from query or to map.
  • If so is it also possible to store value from inner query to key part of map.