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?