function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nagesh ENagesh E 

Use string as condition

How can I use string as condition. For example I will strore Name=="Sam"  in database and use this string in class to check this condition
Pat PattersonPat Patterson
Use a SOQL query like this:

SELECT Id, Name FROM Contact WHERE Name = 'Sam'

So, in an Apex class, you would have:

List<Contact> mylist = [SELECT Id, Name FROM Contact WHERE Name = 'Sam'];