Skip to main content


Showing posts from April, 2014

How to do Auditing in web application with Context Info

Last couple of days I had issues while trying to implement the audit in one of the application.  Especially if tables don’t have the structure to accommodate who modified or when modified fields. So what will do? Is it practical to add all this fields in tables and implement auditing? Yes if you have 5 or 10 tables. What happens if there are 100’s of tables?
 I came across this issue. Fortunately some one told about the ContextInfo. Before starting a database connection set the context info with the current user details. And when the operation finishes call a trigger and update the auditing table with contextInfo.
What time context info update? For all db operation a connection need to open. So conextinfo can be set after the open connection.
 create an OpenConnection() method in the base class which all Execute…() methods call, instead of calling cmd.Connection.Open() directly. Then call SetConext method there.
1. OpenConnectioninternaloverridevoid OpenCon…