If we need our query to include related record data we create an instance of our parent selector. In this case, Accounts and provide the query factory with the relationship.
public List<Contact> selectWithAccountData(){
fflib_QueryFactory contactQueryFactory = newQueryFactory();
new AccountSelector().configureQueryFactoryFields(contactQueryFactory,
Contact.AccountId.getDescribe().getRelationshipName());
return Database.query(contactQueryFactory.toSOQL());
}
Running this query will generate the following query string:
SELECT Account.AccountNumber, Account.Id,
Account.Industry, Account.Name, Account.NumberOfEmployees,
Account.Rating, AccountId,
Email, Id, Name, Phone, Title
FROM Contact
ORDER BY
Name ASC
NULLS FIRST
If we need our query to include related record data we create an instance of our parent selector. In this case, Accounts and provide the query factory with the relationship.
Running this query will generate the following query string: SELECT Account.AccountNumber, Account.Id, Account.Industry, Account.Name, Account.NumberOfEmployees, Account.Rating, AccountId, Email, Id, Name, Phone, Title FROM Contact ORDER BY Name ASC NULLS FIRST