use dapper in a few places (#29)

* use dapper in a few places

* use single dapper queries
This commit is contained in:
Jason Dove
2021-02-23 11:08:48 +00:00
committed by GitHub
parent 38ab6c00ab
commit e2cea69f25
12 changed files with 159 additions and 130 deletions
@@ -0,0 +1,32 @@
using System;
using System.Data;
using Dapper;
namespace ErsatzTV.Infrastructure.Data
{
public abstract class SqliteTypeHandler<T> : SqlMapper.TypeHandler<T>
{
// Parameters are converted by Microsoft.Data.Sqlite
public override void SetValue(IDbDataParameter parameter, T value)
=> parameter.Value = value;
}
public class DateTimeOffsetHandler : SqliteTypeHandler<DateTimeOffset>
{
public override DateTimeOffset Parse(object value)
=> DateTimeOffset.Parse((string)value);
}
public class GuidHandler : SqliteTypeHandler<Guid>
{
public override Guid Parse(object value)
=> Guid.Parse((string)value);
}
public class TimeSpanHandler : SqliteTypeHandler<TimeSpan>
{
public override TimeSpan Parse(object value)
=> TimeSpan.Parse((string)value);
}
}