Firstyll - Apologies! I'm posting a non-LLBL quuery in here
But, the reason is that I respect you guys and your knowledge of .NET, so if anyone has a spare minute to answer my conundrum, I'm very gratefull!
Ok, I have a non-web app (its a console app), that makes constant calls to my BL. My BL methods all instantiate a DataAccessAdaptor, get something, and then return. This is fine, no probs. However, changes have come to light recently that mean that the app.config settings that are needed to connect to the database (connection string, catalog name, etc) are no longer stored in the current applications app.config, they are stored in a web.config file that is shared between a number of apps and the main web app. Heres a (crap) picture:
[Console App] -> [BLL Methods] <- [Web App]
...................................|
...................................|
...................................\/
..........[Read Central Config File]
I have this working... I have created a class that wraps the config file. This class loads the central web.config file as an XML document, and then finds the config setting it needs via a simple XPath query. It works, but I hate it! The performance must be awful, read on...
Say my app calls a BLL method 50 times. Each time the BLL method is called it needs to open a DataAccessAdaptor. So, to do this it first needs to get hold of the connection string. To do this, it calls the config wrapper class I just talked about. This class loads the config file, finds the setting, and uses it. All this happens 50 times! Thats 50 XMLDocuments being loaded, and 50 XPath queries being fired....thats nasty!
I guess what I need to do is cache the connection string (and other values) somehow from the config file, but how and where can I do this? What I don't want to do is have to pass in to my BL methods a connection string to use, thats pretty nasty too.
If it was an ASP.NET only system, I would add the connection string to the cache object, and whenever it was requested in future I could check if it was there or not first.... But its a console app....
Again sorry for posting a non-llblgen topic here...