Wednesday, January 8, 2014

How to solve "Collection was modified; enumeration operation may not execute."?


For IEnumerable collection, need to use ToList first, so you can get same list during the iteration.
                foreach (var qs in one.QuestionSets.ToList())
                {
                    dbc.Questions.DeleteObject(qs.Question);
                }

No comments:

Post a Comment