With the new Database.querywithBinds() method, we can use bind variables as map of String, Object. It also supports multiple values, and even works with list of Sobject. Reference: https://salesforce.stackexchange.com/questions/397098/dynamically-pass-bind-variables-to-a-soql-query-with-querywithbinds-method Below are the code samples: //works with list of String Map<String, object> bindVars = new Map<String, Object>(); bindVars.put('accNames', new List<String>{'Test Acc1', 'Test Acc2', 'Test Acc3'}); String query = 'SELECT Id, Name, Rating FROM Account WHERE Name IN :accNames'; List<Account> accList = Database.queryWithBinds(query, bindVars, AccessLevel.USER_MODE); //works with list of Sobject as well List<Account> accList1 = [SELECT Id FROM Account WHERE Id IN ('0016F00002RrZdsQAF', '0016F00002RrZdtQAF', '0016F00002RrZduQAF')]; Map<String, object> bindVars =