Access Custom Metadata Type Records Using Static Methods

Use the Apex getAll(), getInstance(recordId), getInstance(qualifiedApiName), and getInstance(developerName) methods to retrieve information from custom metadata type records faster. These methods don’t rely on the SOQL engine and return the sObject details directly from the call.

Where: This change applies to Enterprise, Performance, Unlimited, and Developer editions.

Why: The following example uses the getAll() method. The custom metadata type named Games has a field called GameType. This example determines if the field value of the first record is equal to the string PC.
List<Games__mdt> mcs = Games__mdt.getall().values();
boolean textField = null;
if (mcs[0].GameType__c == 'PC') {
   textField = true;
system.assertEquals(textField, true);