The real problem is in .ToArray() calls.
Each of default generic system collections have internal IEnumerator<T> implementation, so compiler knows which types will be used to iterate collection.
The other things happens to arrays like T[]. The mscorlib.dll don't have straightforward implementation of generic arrays (only class System.Array), so the
the solution for that is to make custom wrapper extension like that
public static IEnumerable<T> WrapArray(this T[] array);
and use it before each call to Linq.
As I already said, there is no such problem with List<T> or other built-in generic collections.