Version: 2.5
Templates: Adapter
If anyone has any advice on how to debug the following problem , it would be much appreciated:
When iterating through an entity collection using a foreach loop I get the following error:
**“Collection was modified; enumeration operation may not execute”**
So, i know that this is a .Net error that occurs when the collection that is being iterated is modified… however I am having a hard time pinning down exactly which bit of code it is that modifies the collection – especially as the change almost certainly occurs out of the context of the loop (and as such I can’t just add a “watch” an see when the collection changes).
There is no code directly within the loop that makes any modifications – however, there are several methods called from within the loop that go off and do other things – including queries. I think that somehow the background LLBLGen code that deals with allowing reuse of collections is connected to my problem, and that a collection that is used elsewhere is changing the collection in my foreach loop… I have spent several hours stepping through a lot of code, and not managed to pin it down. I never really fully understood the concept of “Context” within LLBLGen, but i think that may be also connected to the problem (or the solution)!
- Is there a way to peek inside the LLBL Context and see what collections are cached/linked and when they change?
- Is there something else I am missing?
Thanks for any help