Exam4Training

Which technique should be implemented to avoid reaching the governor limit?

A developer must modify the following code snippet to prevent the number of SOQL queries issued from exceeding the platform governor limit. public class without sharing OpportunityService( public static List<OpportunityLineItem> getOpportunityProducts(Set<Id> opportunityIds){ List<OpportunitylineItem> oppLineItems = new List<OpportunityLineItem>(); for(Id thisOppId : opportunityIds){ oppLineItems.addAll([Select Id FROM OpportunityLineItems WHERE OpportunityId = :thisOppId)]; } return oppLineItems; } }

The above method might be called during a trigger execution via a Lightning component.

Which technique should be implemented to avoid reaching the governor limit?
A . Use the System.Limits.getQueries() method to ensure the number of queries is less than 100.
B . Use the System.Limits.getlimitQueries() method to ensure the number of queries is less than 100.
C . Refector the code above to perform the SOQL query only if the Set of opportunityIds contains less 100 Ids.
D . Refactor the code above to perform only one SOQL query, filtering by the Set of opportunityIds.

Answer: B

Latest PDI Dumps Valid Version with 191 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Exit mobile version