I have a two tier architecture based website-data layer and UI layer. I have a web page, I get the id of a customer from the querystring and I build the customer object from that id. I have several tabs in my webpage, so, unless I need the data, I dont have to load the data for the grids which are in the tabs that are not clicked. That's why I use Lazy initialization for the properties of the customer which are not required on page load.
My question is, in page load when I create the customer object, if I add the customer object to session as Session[id]=customerObj, I understand that customerObj gets serialized, but does it mean that all the properties which are lazy initialized get loaded? If so, that will defeat the purpose of using lazy initialization.
I tried to look on MSDN, but could not find good explanation of how this thing is supposed to work. Any inputs is greatly appreci开发者_JAVA百科ated. Thanks!
You can store an object in te session in several ways:
http://msdn.microsoft.com/en-us/library/h6bb9cz9%28VS.71%29.aspx
If you store the object InProc, it stays in the RAM of the webserver and it is not serialized and deserialized, so the properties aren't touched.
That way there is no lazy loading triggered. Your object will stay the same as you left it when you get it back the next postback.
精彩评论