1
0

練習資料庫紀錄完成

This commit is contained in:
2024-03-25 18:18:41 +08:00
parent 3382627c8c
commit 088ec7620a
17 changed files with 119 additions and 22 deletions

View File

@@ -116,4 +116,24 @@ public static IApplicationBuilder UseCoreProfiler(this IApplicationBuilder app)
紀錄的詳細如下:
![LastestProfilingResultDetail](CoreProfilerExampleResource/LastestProfilingResultDetail.JPG)
![LastestProfilingResultDetail](CoreProfilerExampleResource/LastestProfilingResultDetail.JPG)
## CoreProfiler extends DB
CoreProfiler也可用於紀錄SQL執行將原本資料庫使用的<code>Connection</code>替換成CoreProfiler實作的<code>Connection</code>就可以紀錄執行的T-SQL指令。
替換方法如下:
```C#
var connectionString = configuration.GetConnectionString("SQLITE");
var dbProfiler = ProfilingSession.Current != null
? new DbProfiler(ProfilingSession.Current.Profiler)
: null;
return new ProfiledDbConnection(new SqliteConnection(connectionString), dbProfiler);
```
在替換之前先確認CoreProfiler是否有運行的實體才替換資料庫連線執行結果如下:
![LastestProfilingResultDetailForDB](CoreProfilerExampleResource/LastestProfilingResultDetailForDB.JPG)