is it possible to do SOQL for the unknown object without for loop as below

string theQuery = 'Select '+fiels+' From'+obj_frm +whr; Map <Id, object> oppMap = new Map<Id, object>((List<object>)Database.query(theQuery));


You need to use SObject as the value, not Object.

Map<Id, SObject> opportunities = new Map<Id, SObject>(Database.query(...));
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.