2022-01-26 10:43:08 +00:00
|
|
|
|
namespace ASC.Core.Common.EF.Context
|
2020-09-15 13:11:05 +00:00
|
|
|
|
{
|
2020-10-06 11:38:15 +00:00
|
|
|
|
public class MySqlTelegramDbContext : TelegramDbContext { }
|
|
|
|
|
public class PostgreSqlTelegramDbContext : TelegramDbContext { }
|
2020-09-15 13:11:05 +00:00
|
|
|
|
public class TelegramDbContext : BaseDbContext
|
|
|
|
|
{
|
|
|
|
|
public DbSet<TelegramUser> Users { get; set; }
|
|
|
|
|
|
|
|
|
|
public TelegramDbContext() { }
|
|
|
|
|
public TelegramDbContext(DbContextOptions<TelegramDbContext> options)
|
|
|
|
|
: base(options)
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-10-06 11:38:15 +00:00
|
|
|
|
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return new Dictionary<Provider, Func<BaseDbContext>>()
|
|
|
|
|
{
|
|
|
|
|
{ Provider.MySql, () => new MySqlTelegramDbContext() } ,
|
2021-10-12 10:23:20 +00:00
|
|
|
|
{ Provider.PostgreSql, () => new PostgreSqlTelegramDbContext() } ,
|
2020-10-06 11:38:15 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-15 13:11:05 +00:00
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
2020-10-12 19:39:23 +00:00
|
|
|
|
ModelBuilderWrapper
|
2020-10-01 17:08:55 +00:00
|
|
|
|
.From(modelBuilder, Provider)
|
2020-10-05 10:11:15 +00:00
|
|
|
|
.AddTelegramUsers();
|
2020-09-15 13:11:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class TelegramDbContextExtension
|
|
|
|
|
{
|
|
|
|
|
public static DIHelper AddTelegramDbContextService(this DIHelper services)
|
|
|
|
|
{
|
|
|
|
|
return services.AddDbContextManagerService<TelegramDbContext>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|