jta wrote:
Here comes the catch. A product has a lazyloaded collection which is only needed when showing the contents of the shoppingbasket, but the session is now lost. So i have to reattach the Product objects from HttpSessionState to my current ISession using ISession.Lock(myProduct, LockMode.None).
The main benefit I could see of the second-level cache in most instances is the fact that you don't need to handle your own cache expiry. In your specific instance, since you need to manually control some aspect of the retrieval, I think it would be easier to just use the session context.
I do have a question, though. If you have a collection that only needs to be shown on certain pages, would it maybe be cleaner to not lazy-load the collection? Rather, just load the collection external to the Product.
BasketService.GetBasketItems(parentId) or something like that... then you wouldn't need to worry about manually re-attaching the Product.