Hi,
I have a method, GetByID, that retrieves and returns an entity, by its ID. Simple.
But....in my PL (ASP.NET), I store this entity in a session object because its used a lot.
So, I thought I should change my GetByID code so that it does this pseudo-code:
1. If HttpContext available
1.1 If object in session exists with same ID as one requested
1.1.1 Return object from session
Thus, no matter how many lazy calls are made to GetByID, I can be confident that there are no excessive DB hits. But, I don't like tieing the BL to the HttpContext too much, if for example I wrote another PL for it, I would want to do similar checks but obviously I can't work with HttpContext.
Is there a clever solution/pattern of sort for this, or should I go ahead and do what I suggested.....
Thanks all!