I have a classic ASP app that I'm converting to .NET. In the existing app
when accessing infrequntly changed data, it reads a database once a day, and
saves the results in an application variable.
I'm trying to replicate this in .NET, but I'm using a data access layer
(DAL) that's in a seperate project. Obviously, the DAL can't see the
application variables. I was thinking of passing the application state in
the constructor, but this seems like overkill.
Can someone please point me in the direction of a "best practices" guide to
converting legacy application variable caching where an external DAL is
involved, or does anyone have any strong opinions on thie best way to do
this?
Regards,
Duncan
So keeping that in mind:
I would implement a cache object using a singleton in the application. The
singleton pattern creates an object and stores it in a static variable. You
can find quite a few references on the web on creating singletons well in
C#.
This would behave similarly to the use of the app variable from your ASP
app.
Hope this helps,
--- Nick
"Duncan Welch" <du...@ntpcl.f9.co.uk> wrote in message
news:uVTXlGwc...@TK2MSFTNGP10.phx.gbl...
In a web application, you can use HttpContext.Current to reach the
Application collection during processing of a request. I.e.:
HttpContext.Current.Application["MyAppVar"];
Since this ties the DAL to working inside of a web application, I
generally abstract away the source of the cached data with a new
class (or classes, if need be). For a web application the custom cache
class will look into the Application or Cache collections, for a forms
application it might just look into a Hashtable it owns.
HTH,
--
Scott
http://www.OdeToCode.com