RESULT
For more details check SOQLCache Cache API - RESULT.
NOTE! 🚨 All examples use inline queries built with the SOQL Lib Query Builder. If you are using a selector, replace
SOQLCache.of(...)
withYourCachedSelectorName.query()
.
toId​
Apex
Id adminProfileId = [
SELECT Id
FROM Profile
WHERE Name = 'System Administrator'
][0].Id;
SOQL Lib
Id adminProfileId = SOQLCache.of(Profile.SObjectType)
.whereEqual(Profile.Name, 'System Administrator')
.toId();
doExist​
Apex
Boolean adminProfileId = ![
SELECT Id
FROM Profile
WHERE Name = 'System Administrator'
].isEmpty();
SOQL Lib
Boolean isProfileExist = SOQLCache.of(Profile.SObjectType)
.whereEqual(Profile.Name, 'System Administrator')
.doExist();
toValueOf​
Apex
Id profileId = [
SELECT Id
FROM Profile
WHERE Name = 'System Administrator'
][0].Id;
SOQL Lib
Id profileId = (Id) SOQLCache.of(Profile.SObjectType)
.whereEqual(Profile.Name, 'System Administrator')
.toValueOf(Profile.Id);
toObject​
Apex
Profile profile = [
SELECT Id, Name
FROM Profile
WHERE Name = 'System Administrator'
];
SOQL Lib
Profile profile = (Profile) SOQLCache.of(Profile.SObjectType)
.with(Profile.Id, Profile.Name)
.whereEqual(Profile.Name, 'System Administrator')
.cacheInOrgCache()
.toObject()