1

Suppose we have a table, Person with columns - ID, Name, Age, Occupation. User A reads row with id, 1 and updates the name (not saved yet). User B read row id 1 and updates the age (saves) . Then, when user A updates the row. Does user A overwrite the changes to the Age column by User B? Basically, Does calling EF's Savechanges() overwrite the entire row with the latest update? (No concurrency handled).

Thanks.

Arathy T N
  • 306
  • 3
  • 13
  • I misunderstood question. I don't have a DB to test on with LINQ Pad at moment so removing original answer. – Lotok Jul 17 '13 at 21:14
  • This might be of use to you http://stackoverflow.com/questions/3642371/how-to-update-only-one-field-using-entity-framework – Lotok Jul 17 '13 at 21:37
  • I want to know if there is any way to know , based on the values of each column and comparing it with the original value (when it was read) and then include only those columns in the update statement. Like in the scenario I described, the age should not have been overwritten with the User A's value since the value was not changed by A at all. User B's changes should have won but because EF does row update for all columns, the age has been wrongly overwritten – Arathy T N Jul 17 '13 at 22:31
  • The link I posted offers different update options to get address this issue. Can you show your update code for your example? – Lotok Jul 17 '13 at 22:50
  • Thanks for the answer James. Thats is not what I was looking for. I found my solution or rather the approach to my problem here. http://www.prince-kamalanathan.com/tracking-modified-properties-entity-framework/ – Arathy T N Jul 22 '13 at 15:40

0 Answers0