Skip to content

The Soql.SortOrder Class

Jason Siders edited this page Jul 4, 2025 · 4 revisions

Represents a SOQL ORDER BY clause.

Use this object in conjunction with the addOrderBy builder method:

Soql.SortOrder firstCreated = new Soql.SortOrder(
  Account.CreatedDate,
  Soql.SortDirection.ASCENDING
);
Soql query = DatabaseLayer.Soql
  ?.newQuery(Account.SObjectType)
  ?.addOrderBy(firstCreated)
  ?.toSoql();

Constructors

  • Soql.SortOrder(List<String> fieldNames, Soql.SortDirection direction)
  • Soql.SortOrder(String fieldName, Soql.SortDirection)
  • Soql.SortOrder(List<SObjectField> fields, Soql.SortDirection direction)
  • Soql.SortOrder(SObjectField field, Soql.SortDirection direction)
  • Soql.SortOrder(List<Soql.ParentField> fields, Soql.SortDirection direction)
  • Soql.SortOrder(Soql.ParentField field, Soql.SortDirection direction)

Methods

setNullOrder

Adds an optional "null order" clause to the ORDER BY condition. For example, "ORDER BY ExternalId__c ASC NULLS LAST"

  • Soql.SortOrder setNullOrder(Soql.NullOrder nullOrder)
Clone this wiki locally