Link to home
Start Free TrialLog in
Avatar of brettr
brettr

asked on

To use ROWVERSION in LINQ or not?

In .NET 3.5, when I want to update and object and save its results, I query it from the database, assign new values and SubmitChanges().  This means I can overwrite someone else's changes.   As an example, each "T" means time.  DataContexts are created in a using statement:

T1: PersonA queries and loads ID=49 of a Person object and assigns new address without SubmitChanges().
T2: PersonB queries ID=49 of a Person object, updates and SubmitChanges().
T3: PersonA queries ID=49 of a Person, updates with values from T1 and SubmitChanges().

In the example, PersonA wrote over PersonB's changes.  Although not entirely if only one or two properties were being updated.  Everything is fine if PersonB only changed PhoneNumber.  If I go with a  ROWVERSION and keep a DataContext around inside the Person object, what will happen in this situation?

Not using ROWVERSION is the simpler solution but I will always potentially overwrite someone's changes in the above scenario.   What is the best way to handle this case?
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial