In the below code, i am using nested for loops. Could some one guide how can i overcome using nested for loops.
global class batchclass implements Database.Batchable<sObject> {
global final String Query;
global Batchforchattertopics() {
query = 'SELECT Id,createddate,parentId FROM feeditem where (Parent.Type = \'Case\')';
}
global Database.QueryLocator start(Database.BatchableContext BC) {
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<feeditem> scope) {
List<object__c> o = new List<object__c>();
for (feeditem cs : scope) {
for (TopicAssignment t : [select id, topic.name, EntityId from TopicAssignment WHERE EntityId IN = :cs.id]) {
Object__c c = new Object__c();
c.Name = 'Test';
o.add(c);
}
}
insert cfd;
}
global void finish(Database.BatchableContext BC) {
}
}