Hi,

When DO reads objects from the DB which it already has in memory (disconnected state) it does a Version check. Does DO allow for changes in the DB to be taken into memory when no local changes have been made?

Another related question is. Can we order DO to refresh the content of an objects? I.e. reread the data from the DB.

Regards
Paul Sinnema
Diartis AG

asked Jan 10 '11 at 10:46

Paul%20Sinnema's gravatar image

Paul Sinnema
261888896

edited Jan 11 '11 at 03:30

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412


One Answer:

Can we order DO to refresh the content of an objects? I.e. reread the data from the DB.

Yes:

var originalMergeMode = disconnectedState.MergeMode; // MergeMode.Strict by default
disconnectedState.MergeMode = MergeMode.PreferNew;
try {
  // Read some data. It will replace the data in DS in any case.
}
finally {
  disconnectedState.MergeMode = originalMergeMode;
}

MergeMode defines default merge policy for DisconnectedState.

Does DO allow for changes in the DB to be taken into memory when no local changes have been made?

No. I.e. currently you can:

  1. replace know Entity state with the new one
  2. reject new ones, if there is a known Entity state
  3. throw an exception in case there is known + new Entity with conflicting version. Note that "known version" is the version of Entity on the moment it was read for the first time (i.e. not the current one).

In your case we must add a flag like MergeMode.UpdateUnchanged - is it a good solution?

answered Jan 11 '11 at 03:29

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

edited Jan 11 '11 at 03:31

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA