I am trying to structure my code in such a way as to reduce / avoid code duplication, and I came across an interesting problem. Each time my code calls a stored process, I need to pass in several variables that are common to the stored procedure: for example, username, domain, server_ip and client_ip. They all come from either the HttpRequest object or the system.environment object.
Since they are passed to each stored process, my initial thought was to create a utility class, which is a wrapper for the database, and would initialize and pass them each time, so I do not need to do this in my code. The problem is that the C # class (inside the App_Code folder) does not see the Httprequest object. Of course, I could pass this as an argument to the shell, but that would defeat the whole purpose of creating a wrapper. Did I miss something?
I understand that it is not so difficult to repeat 4 lines of code every time I call a stored procedure, but I would rather eliminate code duplication at the earliest stages.
source
share