You need to sign in to do that
Don't have an account?
Andegosu
Best way to assign list from SOQL query result
I always come across two ways of assigning results from a SOQL query to a list and I just wondered if there is any difference between the two:
1. List<Account> exampleOne = [SELECT Id, Name FROM Account WHERE Name = 'John'];
2. List<Account> exampleTwo = List<Account>([SELECT Id, Name FROM Account WHERE Name = 'John']);
1. List<Account> exampleOne = [SELECT Id, Name FROM Account WHERE Name = 'John'];
2. List<Account> exampleTwo = List<Account>([SELECT Id, Name FROM Account WHERE Name = 'John']);
And, there is no difference between tge 2, use whichever you prefer.
All Answers
And, there is no difference between tge 2, use whichever you prefer.