I'm refactoring a recursive function to avoid hitting governor limits on SOQL queries.
In order to keep SOQL queries out of a for loop, I'm using dot notation to retrieve a lookup relation (Residence) that exists on the parent account (household) of the object (wish) being queried.
I had no problem when I had a distinct query on the Household object inside a for loop. But for some reason, I can't use the Residence as the parameter on the recursive call.
Here's my call
// GET THE FOLLOWING DATA FOR EACH WISH AGAINST THE TARGET PROPERTY
// Wish Name
// Name and Id of parent Household (ie Owner of this wish)
// Name and Id of parent Household's Residence (may be null)
List<Wish__c> wishes = new List<Wish__c>([ SELECT Name,
WHERE Property__c = :targetProperty.Id]);
Which works just fine to get me the id I want
But when I try to use either Household__r.Residence__c or Household__r.Residence__r.id in the call to the recursive function, I get the following error
Method does not exist or incorrect signature: void findDaisyChains(Integer, Id, DaisyChainFinder.daisyChain, Integer) from the type DaisyChainFinder
The call looks like this
findDaisyChains(step+1, thisWish.Household__r.Residence__c, daisyChainToUse, maxSteps); // increment the step and execute recursive call
The function is declared as follows
private static void findDaisyChains(Integer step, Property__c targetProperty, daisyChain thisDaisyChain, Integer maxSteps)
It's expecting a property, but won't accept either way of passing it the id of a property.