A custom Selector method with a custom dataset

SOQL has a very rich dot notation to traverse relationship (lookup) fields in order to access other fields on related records within a single query. To obtain the following information in a tabular form, it needs to traverse up and down the relationships across many of the objects in the FormulaForce application object schema:

  • The season name
  • The race name
  • The race position
  • The driver's name
  • The car name

First, let's consider the following SOQL and then look at how it and the data it returns can be encapsulated in a ContestantsSelector class method. Note that the common order by clause is also applied here, as was the case in the previous example:

select Race__r.Season__r.Name, Race__r.Name,RacePosition__c, ...

Get Salesforce Lightning Platform Enterprise Architecture - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.