run
Run the query as if running Database.query()
.
public List run()
Returns a list of SObject.
Alias to toSObjectList()
.
List accounts =
new Query('Account').
run();
Run the query as if running Database.query()
.
Returns a list of SObject.
Alias to toSObjectList()
.
List accounts =
new Query('Account').
run();
Fetch a subset of the result.
Fetch the first SObject from the result.
Returns an SObject.
Account account =
(Account)
new Query('Account').
fetch();
Fetch the n elements from the result.
n: Indicates the number of elements.
Returns an SObject.
Account account =
(Account)
new Query('Account').
fetch(2);
Fetch a subset of result in the range [first, last).
Returns a list of SObject.
List accounts =
new Query('Account').
fetch(2, 4);
Run the query as if running Database.query()
.
Returns a list of SObject.
Alias to run()
.
List accounts =
new Query('Account').
toSObjectList();
Run the query and return the Id list of the result.
Returns a list of Id.
List accounts =
new Query('Account').
toIdList();
Get the QueryLocator that can be used for Batch Apex.
Returns a Database.QueryLocator.
Database.QueryLocator locator =
new Query('Account').
selectAllFields().
getQueryLocator();
Get the result of the aggregated query.
Can only be used with aggregate functions.
Get the result of the aggregated query.
Returns a List of AggregateResult.
The returned list is guaranteed to be non-empty.
List result =
new Query('Account').
count('Name').
aggregate();
Get an executable SOQL string that can be used in Dateabase.query()
.
Returns an executable SOQL string.
String queryStr = new Query('Account').
selectAllFields().
run();
List accounts = Datebase.query(queryStr);
Contribute on Github! Edit this section.