WHERE
The condition expression.
SELECT Id, Name
FROM Account
WHERE Id = :accountId OR Name LIKE :'%' + accountName + '%'
public inherited sharing class AccountSelector {
public static SOQL query {
get {
return SOQL.of(Account.SObjectType)
.with(new List<SObjectField>{
Account.Id,
Account.Name
});
}
}
}
public with sharing class MyController {
public static List<Account> getByIdOrName(Id accountId, String accountName) {
return AccountSelector.query
.whereAre(SOQL.FilterGroup
.add(SOQL.Filter.id().equal(accountId))
.add(SOQL.Filter.with(Account.Name).contains(accountName))
.conditionLogic('1 OR 2')
)
.toList();
}
}