Your guess is almost correct as I'm on WPF, but that probably doesn't matter.

Can you point me to any documentation on the conversation stuff? I can't find 
anything on the AR web site.
I tried to initialize a ScopedConversation when I configure AR but without a 
global session scope AR explodes as soon as I try to access a lazy loaded 
property in my front-end code. And keeping a global ConversationalyScope will 
probably be as bad as keeping a global SessionScope, right?

/Christian

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Nicholas Kilian
Sent: den 30 mars 2011 10:50
To: [email protected]
Subject: RE: AR and a stale transaction

I guess you're on winforms? Take a look at ConversationalScope and 
ScopedConversation.

There was an article on it somewhere, but I think it got lost in the move to 
the new docs site.

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Christian Axelsson
Sent: 30 March 2011 10:42 AM
To: [email protected]
Subject: AR and a stale transaction

Hello,

I try to persist an entity to database using 

  myEntityRepository.Save(myEntity); // This will end up calling 
ActiveRecordMediator.Save(entity);
  SessionScope.Current.Flush();

By configuring AR to show SQL in output window I see that the update hits 
database but for some reason it isn't committed to DB. Investigating further I 
see that I'm stuck with an open transaction meaning that the whole table is 
locked until my session scope is disposed (upon application exist).

Currently I create a session scope when AR is initialized and leave it there. 
Wrapping the save statement inside a new TransactionScope "fixes" the problem 
but I find that kind of ugly. Manually disposing the current session scope and 
recreating it also works but that is quite ugly as well I think.
It feels like using a "global" session scope like this isn't really the way to 
go but if I don't create a session scope before starting to throw queries at AR 
lazy loading breaks.

Any hints on how to solve this?

/Christian

--
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.

--
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to