I have an IQueryable object and I want to update some values manually, but the changes are not reflected after the loop is executed:
IQueryable<myModel> items;
items = GetItems();
foreach (myModel row in items)
{
row.field10 = "new value";
}
objDataContext.SubmitChanges();
What am I doing wrong?
Does
GetItems()method use exactly the same instance ofobjDataContextto get the items from the database? It has to use the sameObjectContextto keep track of changes. Another option is to use theToList()method: