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
|
Is it possible to have multiple "PerRequestUnitOfWorkScope" objects for the same LightSpeedContext? I'm using LightSpeed within an ASP.NET Content Management System that has pluggable "modules" and I'm seeing an issue where if I have 2 different modules that are each trying to use LightSpeed, they are sharing the same "PerRequestUnitOfWorkScope.Current" object, even though I am storing them in the HttpContext.Current.Items[] dictionary with different keys! For each module, I'd like it to have it's own instance of PerRequestUnitOfWorkScope, since they can have completely different models and will talk to different database tables. However, the LigthSpeedContext would be the same (since they are talking to the same database). What is the recommended way to accomplish this? Does my scenario make sense? |
|
|
No. The PerRequestUnitOfWorkScope's semantics are 'unit of work per request,' not 'unit of work per scope object.' So when you create a new scope object, it will return the unit of work associated with the current request -- NOT a new unit of work. (As a side note, this means there's no need to store scope objects in the HttpContext -- you can just create a new one whenever you need to get at the request UOW.) To get what you want, you'll need to either implement your own "PerRequestAndModuleUnitOfWorkScope" class, or manually store UOWs on a per-module basis in the HttpContext. (These actually boil down to the same implementation -- just the first wraps it up in a handy class!) We'd be happy to provide you with the PerRequestUnitOfWorkScope source code as a starting point if that would help. |
|
|
I see. I was looking at the FilmFestival MVC app in the Samples and saw in the FilmFestivalController class that you guys were storing the PerRequestUnitOfWorkScope in the HttpContext with a specific string key, so that's what I thought needed to be done. If you can send me the source code for that class that would be fantastic, as I think I will need to implement something like "PerRequestAndModuleUnitOfWorkScope" for my application. Should I still keep an application level "LightSpeedContext" and share that across each "PerRequestAndModuleUnitOfWorkScope" ? (In other words, I don't need a separate/new LightSpeedContext for each UoW instance) |
|
|
Correct. Unless you're talking to multiple databases at the same time, you would have only one LightSpeedContext across the application. http://www.mindscapehq.com/forums/Thread.aspx?ThreadID=3782 explains more. I've attached the PerRequestUnitOfWorkScope source code. Should be pretty clear how it works. Probably the only modification is to make it use a per-module key instead of a fixed key. Let us know if you have any questions! |
|
|
I'm not able to download the attachment, getting a 404 error |
|
|
Oops, sorry, we made some changes to our Web site configuration recently and it looks like we accidentally reverted some file type whitelistings. Try this zip file version, or if that fails let me know and I'll just paste the code in! |
|
|
Thanks, got it! |
|