I want to create an overview of a list which contains content from different objects. I will try to add in this list the files, tasks, events, emails and notes. If I query for each object a list, how can I concatenate all these lists into one list. Is that possible because of different object and structure?
Yes, you can.
sObject can hold any type of database record, such as:
sObject results = new sObject; results.addAll([SELECT Title FROM ContentDocument]); results.addAll([SELECT Subject FROM Task]); results.addAll([SELECT Subject FROM Event]); results.addAll([SELECT Subject From EmailMessage]); results.addAll([SELECT Title FROM Note]);
If you decide you want to use a Data Transfer Object (DTO) model in your code, you can also decide to use a parent DTO object type, or even just
Object, which is the parent of all object types.