Save modification only and concurent modification

Feb 20, 2015 at 7:48 PM
I have 2 questions again ;)

when saving a modified object, is it possible to save only fields that have been changed? I also wonder if in NRepository, there is a managing concurrent changes.

Person A - GetObject
Person B - Get Object
Person B - modify and save Object (good)
A Person -modify and save older data (BAD) Is there a way to get an exception raised?
Coordinator
Feb 21, 2015 at 4:53 PM
Edited Feb 21, 2015 at 4:54 PM
Question 1. partial updates.

In EF you get this for free if you : 1. Ensure dbContext.Configuration.ProxyCreationEnabled = false & 2. don't call the NRepository Modify method before calling save( under the hood the modify calls 'DbContext.Entry(p).State = EntityState.Modified)' which basically sets all the fileds to modified.) To get what you want simply set the individual properties and then call save. To see what is exactly going on between EF and the database i recommend you download Express profiler 2.0 and have a look at the logs.

Question 2. 'Concurrency'
This functionality is really outside the scope of NRepository. There's plenty of documentation on how to do this on the net. Have a look at http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/handling-concurrency-with-the-entity-framework-in-an-asp-net-mvc-application, this should point you in the right direction :)
Feb 22, 2015 at 8:39 PM
And dor mongodb ?