This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I just changed over some of our code to use the PerRequestUnitOfWorkScope but now one of our Entities is throwing an ObjectDisposedException when we try to access it's UnitOfWork property with an aggregate Any ideas on how this Entity could be accessing a UnitOfWork outside of a request? |
|
|
The exception stack trace should give you some idea of what code is using the entity. The most likely cause I can think of is that the entity is still attached to an old unit of work, rather than the UOW of the current request. This could happen if you put an entity into session state for example -- when you retrieve the entity from session, the request which instantiated the entity is over and its UOW has been disposed -- basically anything that holds a reference to the entity beyond the life of a single request. |
|
|
This seems to be exactly what is happening. I will ask around and find out how we use Sessions here. Are there any common patterns or ways of using Sessions with LightSpeed I should know about? |
|
|
There are a few relevant forum posts (mostly a bit old but still relevant): http://www.mindscapehq.com/forums/Thread.aspx?PostID=9132 http://www.mindscapehq.com/forums/Thread.aspx?PostID=4862 http://www.mindscapehq.com/forums/Thread.aspx?PostID=7852 As you'll see, we generally recommend against storing entities in session. It can just about be done with Attach, Detach and a great deal of good fortune, but it's far safer to store IDs and use caching to keep performance up. I'm a bit surprised we don't seem to have captured this guidance in the user guide -- I'll file a bug for us to update the relevant section. |
|