I'm getting a parent record which is Account acc, and a list of Contacts listContact from another process.
Now in order to proceed further I need to do something I could do like:
Account acc = [select Id, (select Id from Contacts) from Account limit 1];
I tried to do acc.Contacts = listContact;
which is a compile time error. (Field is not writeable: Account.Contacts)
I am able to do acc.Contacts.addAll(listContact);
but when I access/print acc.Contacts, it returns nothing.
Is there any way to assign the related child record to the parent variable?