use dapper in a few places (#29)
* use dapper in a few places * use single dapper queries
This commit is contained in:
+12
-3
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Channels;
|
||||
using Dapper;
|
||||
using ErsatzTV.Application;
|
||||
using ErsatzTV.Application.Channels.Queries;
|
||||
using ErsatzTV.Core;
|
||||
@@ -27,6 +29,7 @@ using FluentValidation.AspNetCore;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -109,17 +112,23 @@ namespace ErsatzTV
|
||||
// string xmltvPath = Path.Combine(appDataFolder, "xmltv.xml");
|
||||
// Log.Logger.Information("XMLTV is at {XmltvPath}", xmltvPath);
|
||||
|
||||
var connectionString = $"Data Source={FileSystemLayout.DatabasePath}";
|
||||
|
||||
services.AddDbContext<TvContext>(
|
||||
options => options.UseSqlite(
|
||||
$"Data Source={FileSystemLayout.DatabasePath}",
|
||||
connectionString,
|
||||
o =>
|
||||
{
|
||||
o.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery);
|
||||
o.MigrationsAssembly("ErsatzTV.Infrastructure");
|
||||
}));
|
||||
|
||||
services.AddDbContext<LogContext>(
|
||||
options => options.UseSqlite($"Data Source={FileSystemLayout.LogDatabasePath}"));
|
||||
services.AddDbContext<LogContext>(options => options.UseSqlite(connectionString));
|
||||
|
||||
services.AddTransient<IDbConnection>(_ => new SqliteConnection(connectionString));
|
||||
SqlMapper.AddTypeHandler(new DateTimeOffsetHandler());
|
||||
SqlMapper.AddTypeHandler(new GuidHandler());
|
||||
SqlMapper.AddTypeHandler(new TimeSpanHandler());
|
||||
|
||||
services.AddMediatR(typeof(GetAllChannels).Assembly);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user