String[] filters = new String[0];
if(firstName != null) {
filters.add('FirstName = :firstName');
}
if(lastName != null) {
filters.add('LastName = :lastName');
}
// ... many more ... //
String query = 'SELECT Id FROM Contact ';
if(filters.size() > 0) {
query += ' WHERE ' + String.join(filters, ' AND ');
}
return Database.query(query);
No comments:
Post a Comment