Here is my query:
List<object1__c> lstRecords = [SELECT field1__c, field2__r.Name FROM Object1__c];
populateData((List<sObject>)lstRecords);
//I need to pass sObject, since this function would be used for multiple objects
public void populateData(List<sObject> lstRecords){
System.debug(lstRecords[0].get(field1__c)) //This works fine
System.debug(lstRecords[0].get(field2__r.Name)) //This does not work
}
The query debug shows following:
Object1__c:{field1__c=data} //I don't see the field
Any solution for the above?