function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Federico SosaFederico Sosa 

Why do I need to use Schema instead a Dml

Hi,
My question is: why do we need to use the Schema to get some information instead using a Dml to get the same information?
An example:

contactRTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByName().get(CONTACT_RECORDTYPE_NAME).RecordTypeId;

OR

contactRTypeId = [SELECT Id FROM RecordType WHERE Name = :CONTACT_RECORDTYPE_NAME].Id;

Thanks in advance,
Federico.
AadryanAadryan
Save SOQL.. Governor Limits ;-)