Reputation: 398
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?
Upvotes: 5
Views: 9755
Reputation: 18149
Does GetItems()
method use exactly the same instance of objDataContext
to get the items from the database? It has to use the same ObjectContext
to keep track of changes. Another option is to use the ToList()
method:
List<myModel> items = GetItems().ToList();
Upvotes: 3