SubQuery
of
Conctructs an SOQL
.
Signature
SubQuery of(sObjectType ofObject)
Example
//SELECT Id, (SELECT Id FROM Contacts) FROM Account
SOQL.of(Account.sObjectType)
.with(SOQL.SubQuery.of('Contacts'))
.asList();
select
with fields
Signature
SubQuery with(List<sObjectField> fields)
Example
//SELECT Id, (SELECT Id, Name FROM Contacts) FROM Account
SOQL.of(Account.sObjectType)
.with(SOQL.SubQuery.of('Contacts')
.with(new List<sObjectField>{
Contact.Id, Contact.Name
})
)
.asList();
with related fields
Signature
SubQuery with(String relationshipName, List<sObjectField> fields)
Example
//SELECT Id, (SELECT CreatedBy.Id, CreatedBy.Name FROM Contacts) FROM Account
SOQL.of(Account.sObjectType)
.with(SOQL.SubQuery.of('Contacts')
.with('CreatedBy',
User.Id, User.Name
})
)
.asList();