I am using EF5 and I am getting an error when I am calling context.SaveChanges in a for loop.
If I am updating any entity, do I need to call SaveChanges to get the updated value of the entity with in the same context.
For example,quantity of one line item is n. In my firts iteration I am reducing the quantity of line item by 1. So now the actual quantity is n-1. I have not yet called SaveChanges on context. In the next iteration for the same line item is the quantity would be n or n-1?
Thanks
I’m not quite sure what you are trying to do, but you definitely shouldn’t call SaveChanges in a loop. Make all the changes you need in a loop (add, remove or whatever on context), and when you’re finished, call SaveChanges.