using Dapper; using Elsa.Dapper.Contracts; using Elsa.Dapper.Services; using Elsa.Dapper.TypeHandlers.Sqlite; using Elsa.Features.Abstractions; using Elsa.Features.Services; using Microsoft.Extensions.DependencyInjection; namespace Elsa.Dapper.Features; /// /// Configures common Dapper features. /// public class DapperFeature : FeatureBase { /// public DapperFeature(IModule module) : base(module) { // See: https://learn.microsoft.com/en-us/dotnet/standard/data/sqlite/dapper-limitations#data-types SqlMapper.AddTypeHandler(new DateTimeOffsetHandler()); SqlMapper.AddTypeHandler(new GuidHandler()); SqlMapper.AddTypeHandler(new TimeSpanHandler()); } /// /// Gets or sets a factory that provides an instance. /// public Func DbConnectionProvider { get; set; } = _ => new SqliteDbConnectionProvider(); /// public override void Apply() { Services.AddSingleton(DbConnectionProvider); } }