Payment1 and Payment2 has a lookup relationship with Case. Now I need to write a SOQL to get call its child object dynamically. Case could have record for Payment1 or Payment-2 or both Payment-1 and Payment-2.
List<Case> caseList = [Select Id,OwnerId, (select Id, OwnerId, CreatedById from Payment__r),
(select Id,OwnerId,CreatedById from Payment_2__r)
FROM Case
WHERE Id IN :newCasesMap.keySet()];
How to identify the Payment-1 only present or Payment-2 only present or both Payment1 and Payment-2 present ?