i’m developing an asp.net application. In my database i’ve a “classic” mono-record settings table.
Each time i need a setting, i write some code like this
if ReturnSetting("my_setting") = value then
'do something
else
'do others
end if
In ‘ReturnSetting’ i open a connection, get the setting value and return it.
This is not efficient (open connection, datareader etc.)
How can i optimize this ?
Thank you
I think you can write the call to the function on the Global.asax file in the application start event to load this data once from the database and put the result in an application object and update your “ReturnSetting” function to check for the application object and this will optimize your code so that the database call is done once.
N.B. This solution will work effectively if this is global web site settings but if it is a user setting so you have to use the Session Start event in the global.asax and the session to store the data in.