Unfortunately, DisconnectedState has been removed!

DisconnectedState will used in a lot of WPF dialogs with the function Merge(). It was the only way to use global cached data in several other client sessions without unwanted database access (tip from Alex Yakunin - 3 years ago).

How can this functionality be replaced - without many new code?

asked Aug 29 '14 at 09:10

TeaMan's gravatar image

TeaMan
140141418


One Answer:

Hello TeaMan

I see you already found the solution. we reworked client profile. Old implementation was very slowly. Now it is better.

For another people, who will read this topic. In 5.0 we removed DisconnectedState from DO, because it was slowly and had very complicated implementation. It was a part of ClientProfile mode. We reworked ClientProfile mode. So, now if you set option SessionOptions.ClientProfile to session then you can read entities from database without open transaction. Also, as in old Client profile, you can create new instances of entity without opened transaction (and without persisting of changes on DO demand) and save them when you need using Session.SaveChanges() or cancel it using Session.CancelChanges().

For example,


var domain = Domain.Build(domainConfiguration);
//Auto activation is not necessary option, 
//but if you do not set it then you need activate session manually
sessionConfiguration = new SessionConfiguration(
  SessionOptions.ClientProfile | SessionOptions.AutoActivation);

using (var session = domain.OpenSession(sessionConfiguration) { var author = new Author {Name = "Some author"}; var firstBook = new Book {Authors = {author}, Title = "first book"}; var secondBook = new Book {Authors = {author}, Title = "second book"}; session.SaveChanges(); //saving changes //session.CancelChanges(); // or cancel changes if you need }

if you use code like that in old client profile,


...
using (session.DisableSaveChanges()) {
// some code
}
...
then you need to change your code, because we removed this method because it was based on old DisconnectedState.

answered Sep 01 '14 at 00:35

Alexey%20Kulakov's gravatar image

Alexey Kulakov
51215

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