DocSpace-buildtools/common/ASC.Webhooks.Core/Dao/WebhooksDbContext.cs

47 lines
1.4 KiB
C#
Raw Normal View History

#nullable disable
2021-08-26 18:43:41 +00:00
namespace ASC.Webhooks.Core.Dao
{
2021-08-19 09:11:26 +00:00
public class MySqlWebhooksDbContext : WebhooksDbContext { }
public class PostgreSqlWebhooksDbContext : WebhooksDbContext { }
public partial class WebhooksDbContext : BaseDbContext
{
public virtual DbSet<WebhooksConfig> WebhooksConfigs { get; set; }
2021-09-03 14:02:52 +00:00
public virtual DbSet<WebhooksLog> WebhooksLogs { get; set; }
2021-08-19 09:11:26 +00:00
public WebhooksDbContext() { }
public WebhooksDbContext(DbContextOptions<WebhooksDbContext> options)
: base(options)
{
2021-08-19 09:11:26 +00:00
}
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
{
get
{
2021-08-19 09:11:26 +00:00
return new Dictionary<Provider, Func<BaseDbContext>>()
{
{ Provider.MySql, () => new MySqlWebhooksDbContext() } ,
2021-10-29 17:02:45 +00:00
{ Provider.PostgreSql, () => new PostgreSqlWebhooksDbContext() } ,
2021-08-19 09:11:26 +00:00
};
}
}
2021-08-19 09:11:26 +00:00
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
ModelBuilderWrapper
.From(modelBuilder, Provider)
.AddWebhooksConfig()
2021-09-03 14:02:52 +00:00
.AddWebhooksLog();
}
2021-08-19 09:11:26 +00:00
}
2021-08-19 09:11:26 +00:00
public static class WebhooksDbExtension
{
public static DIHelper AddWebhooksDbContextService(this DIHelper services)
{
return services.AddDbContextManagerService<TenantDbContext>();
}
}
}