-
Notifications
You must be signed in to change notification settings - Fork 18
Callsite tracking
sdrapkin edited this page Apr 11, 2017
·
1 revision
Callsite tracking is a unique feature of TinyORM which allows SQL Server to be aware of the source code location which invoked that query. The source code callsite information includes:
- source file name, from which the TinyORM query was invoked
- source line #
- source method name that contains the invoked TinyORM query
Every TinyORM query includes a hidden @@ct parameter, which contains the following sample data:
@@ct='C:\Users\Administrator\AppData\Local\Temp\LINQPad5\_dlfidaql\query_jvbunq.cs57Main'The @@ct sample above consists of:
- file name:
C:\Users\Administrator\AppData\Local\Temp\LINQPad5\_dlfidaql\query_jvbunq.cs - line #:
57 - method name:
Main
If you capture your SQL Server traffic with SQL Server Profiler, you can easily trace any TinyORM query to its callsite (ie. the originating source code location).
You can also capture callsite info in a Trigger (ex. for auditing purposes):
(await db.QueryAsync("SELECT REPLACE(SUBSTRING(CONTEXT_INFO(),17, 128),'\0','') as [CT]")).Dump();
// prints:
// Key: CT
// Value: C:\Users\Administrator\AppData\Local\Temp\LINQPad5\_dlfidaql\query_wkpkxx.cs55MainCopyright (c) 2016-2022 Stan Drapkin