練習資料庫紀錄完成
This commit is contained in:
30
CoreProfilerExample.Common/Options/DatabaseOption.cs
Normal file
30
CoreProfilerExample.Common/Options/DatabaseOption.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using CoreProfiler;
|
||||
using CoreProfiler.Data;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CoreProfilerExample.Common.Options
|
||||
{
|
||||
public class DatabaseOption(IConfiguration configuration) : IDatabaseOption
|
||||
{
|
||||
public IDbConnection SqliteConnection
|
||||
{
|
||||
get
|
||||
{
|
||||
var connectionString = configuration.GetConnectionString("SQLITE");
|
||||
|
||||
var dbProfiler = ProfilingSession.Current != null
|
||||
? new DbProfiler(ProfilingSession.Current.Profiler)
|
||||
: null;
|
||||
|
||||
return new ProfiledDbConnection(new SqliteConnection(connectionString), dbProfiler);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user