You can avoid it by materializing the query, f.e. by using ToList()
:
var regulations = LoadRegulations("moduleName").ToList();
It's due to the nature of deferred execution
of the yield return
.
What is the purpose/advantage of using yield return iterators in C#?