One of the scenario that become when we work with ORMs, is the data reliability. There are any cases in which the data we are consuming, are prior changed from another user or application, and we need to sync this data before to use it.
Supposing we are using Linq2SQL, we could resolve this issue, simply executing a refresh on the instance (or the instances) that we are working on, to reload any or all the values from the database onto our instance.
The following is an example:
// myDataContext is a Linq2SQL Data Context
myDataContext ctx = new
myEntityType instance = ctx.myEntityTypeSet.Where(set => set.ID == 1).Single();
// this is the refresh statement
Values that can be assigned to RefreshMode enumeration are the following:
We can define the this parameter, in order to preserve the local changed values, or reload all values from database, overwriting local changes.