In this post, we will see How To Run SOQL Queries in Apex Programming Language | SOQL in Apex | Salesforce Development
Program Code (Anonymous Window):
List<Student__c> records=[SELECT Id, Name, Roll_Number__c, Dept__c FROM Student__c];
for(Student__c record:records)
{
System.debug('Name:'+record.Name+' Roll No.'+record.Roll_Number__c);
}
Map<ID,Student__c> recordsMap=new Map<ID,Student__c>([SELECT Id, Name, Roll_Number__c, Dept__c FROM Student__c]);
for(Student__c record:recordsMap.values())
{
System.debug('Name:'+record.Name+' Roll No.'+record.Roll_Number__c);
}
No comments:
Post a Comment