I'm trying to query a data table called "Nations" from a DataContext
object and receive the following exception when calling SubmitChanges()
:
Collection was modified; enumeration operation may not execute
Below is a snippet of the code:
foreach (Nation thisNation in NationList)
{
Nation nation = nationDB.Nations.Where(c => c.ID == thisNation.ID).First();
nation.Duplicate(thisNation);
}
Where Duplicate()
is a method that copies some properties of a Nation
object:
I'm using EF with CTP5.
What am I doing wrong?