Tuesday, October 13, 2015

Reducing Salesforce SOQL queries by using static variables

public static List myObjectList {
     get {
          if (myObjectList == null) {
               myObjectList = [
                    select Name
                    from MyObject__c
               ];
          }

          return myObjectList;
     }
     set;
}