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
|
Hi, in my code, on websites I access UoW this way, and my question is, if this way is still per-request thread safe, when I access it through static property and context and UoW scope are static too?
In my business layer I use it all such as this:
Thank you, Pooik |
|
|
Yes, this is request-safe. Although the PerRequestUnitOfWorkScope instance is static and therefore shared between requests, the Current property backs onto the current Request object, and it will therefore return a different unit of work for each HTTP request (but the same unit of work throughout the same HTTP request). And having the LightSpeedContext as static (or otherwise as a singleton) is recommended both for convenience and for internal efficiency reasons. The one thing to be aware of is that your pages should not modify that shared LightSpeedContext. For example, if one page sets LightSpeedContext.Logger, then that will affect all units of work. However, the LightSpeedContext should generally be treated as immutable after initialisation (except for diagnostic and testing scenarios) so that shouldn't be an issue in production code. |
|
|
Great, thank you :) |
|