Search code examples
asp.netsession-state

asp.net retrieving/persisting session object from SQL server


I have an application that is using SQL Server to store sessions. I have a session object in the base page wrapped as a Property that I am using through out the application. The property is retrieving the session as:

Dim myObj As Customer = CType(HttpContext.Current.Session("CustomerSession"), Customer)

1) Is myObj is a Reference object or is a local variable?

2) Also, if I get/set properties of myObj as:

Dim firstName as String = myObj.FirstName
myObj.FirstName = "test 12313"

Does the above Get/Set FirstName makes a call to database? Or it is only Retrieving/Setting the value to local variable until the object is persisted back to the Session which means saving to the SQL Server database like this:

HttpContext.Current.Session("CustomerSession") = myObj

Solution

  • ya because its hard for sql server track changes for each session variable and update it..