This is a subtle one.
You correctly assume that a method like
void SomeMethod(IQueryable<T> query)
can modify the reference object it receives and that these modifications will be visible outside the scope of the method.
However... the method doesn't modify the object, it replaces it. The assignment =
assigns the return value of the Include
method to the query
variable. Now inside the method, the previous query
variable is out of scope, because the reference is overwritten by a reference to the new object. But outside the method this new reference will never be known. There the old reference still applies.
The remedy is simple: return the new reference:
IQueryable<T> SomeMethod(IQueryable<T> query)
In you case this would become:
accountQuery = AddBillingConfigurationAccountIncludes(accountQuery);
If you don't believe me, try this little program in Linqpad :)
void Main()
{
var ints = Enumerable.Range(1,10).ToArray();
AddInt(ints, 11);
ints.Dump();
}
void AddInt(IEnumerable<int> list, int i)
{
list = list.Concat(new[] {i});
list.Dump();
}