1
0
Files
CoreProfilerExample/CoreProfilerExample.Common/Options/DatabaseOption.cs
2024-03-25 18:18:41 +08:00

31 lines
860 B
C#

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);
}
}
}
}