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
AbAb 

creating a map of id, class

Hello,

I have below loop where is loop across accounlist and create few set.

Loop{
populate set 1
populate Set 2
}

use set 1
use set 2

Is there a way to create a map something like:
private static Map<Id, ResourceDTO> tempmap     = new Map<Id, ResourceDTO>();
 
private class ResourceDTO {
                       
    public string id {get; set;}             
    public string name {get; set;}
    public string documenttype {get; set;}
    public string documentcategory {get; set;}
    public string filetype {get; set;}                       
    public string content {get; set;}
    public List<string> permissions {get; set;}
    public string publishdate {get; set;}
    public string lastmodifieddate {get; set;}
}

how can i access them , please 

 
Best Answer chosen by Ab
CharuDuttCharuDutt
Hii Sandrine
Try Below Code
map<Id,ApexClass> lstmap = new map<Id,ApexClass>();
list<ApexClass>lstCls = [SELECT Id, Name, NamespacePrefix, BodyCrc, Body, LengthWithoutComments, Status, IsValid FROM ApexClass where Name like '%ResourceDTO %'];
for(ApexClass apx : lstCls){
    lstmap.put(apx.Id,apx);
    system.debug(lstmap);
}
Please Mark It As Best Answer If It Helps
Thank You!

All Answers

CharuDuttCharuDutt
Hii Sandrine
Try Below Code
map<Id,ApexClass> lstmap = new map<Id,ApexClass>();
list<ApexClass>lstCls = [SELECT Id, Name, NamespacePrefix, BodyCrc, Body, LengthWithoutComments, Status, IsValid FROM ApexClass where Name like '%ResourceDTO %'];
for(ApexClass apx : lstCls){
    lstmap.put(apx.Id,apx);
    system.debug(lstmap);
}
Please Mark It As Best Answer If It Helps
Thank You!
This was selected as the best answer
AbAb

Hi Charu,

the apex class is the public class, how can i create it, it is not an object