I've read --while trying to figure this out-- that with temporary tables there's the notion of a session in SQL Server. However, I have not been able to find any documentation regarding what exactly constitutes as a SQL Server session.
With this information, I'd like to implement some basic logging functionality.
My problem is that I have context which (currently) exists only in my application. I'd like to push this context to the database, say, if there was such as thing as custom SQL Server connection properties, I would wanna use that.
My idea is to create a #
local temporary table with the context information prior to any work (application specific SQL) being executed and to write triggers that would fetch information from this temporary and summarize that in a general purpose logging table.
I'd like some insight on who to best push context onto the database (from an application) and then do something with it. e.g. triggers and such.
I'm using Linq2Sql for my database objects and I'm a bit unsure how I would be able to hook this up so that for each DataContext.SubmitChanges
the appropriate context is set for each connection involved. In my mind, this should equate to some custom SQL being executed just before SubmitChanges
but in practice DataContext.ExecuteCommand
and SubmitChanges
are two different things and what guarantee do I have, that it's the same connection or (session as it's being referred to in the SQL Server documentation on MSDN).
Update: Details
- The application is a web application, the context is some properties in conjunction with an authenticated user (a.k.a. ASP.NET session state items).
- I'm using connection pooling by default, I have on intent of disabling this.
- The solution does not have to be flexible, but it will have to be robust (this is why I move things into the database server, the purpose of this is to maintain dependable auditing information).