One class for every query

Posts   
1  /  2
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 21-Oct-2005 02:18:19   

Back to the original question...

EntityHelper.QueryRequests.Add( "States", States.GetAll() );

'States.GetAll()' is going to have to return an object which describes the query or at least identifies it. But lets say I want to write really pure code and I don't want any SQL to be generated unless the results aren't in the cache.

So how can a request be made to this DAL such that the DAL first looks in the cache for the result and then only if the result is not there does it generate the SQL?

Of course, my solution was to pass an instance of a class with overriden methods such that the DAL can call the methods to create the SQL if necessary. But then there's one class for every query. To avoid this perhaps one could pass an object with the code to generate the SQL plugged into an event?

What do you think?

pilotboba
User
Posts: 434
Joined: 05-Aug-2005
# Posted on: 21-Oct-2005 16:03:09   

Ian wrote:

Back to the original question...

Yes, my code snippet was just a basic idea of a pattern I would try to emply rather than a production impelmentation thereof. But, you are right, you would have to provide some way to know what Entity the PredicateExpression goes with.

After all, this is the Architecture category. wink

BOb

1  /  2