DocSpace-buildtools/common/ASC.Core.Common/EF/Context/FilesDbContext.cs

35 lines
1.0 KiB
C#
Raw Normal View History

2022-02-15 11:52:43 +00:00
namespace ASC.Core.Common.EF.Context;
public class MySqlFilesDbContext : FilesDbContext { }
public class PostgreSqlFilesDbContext : FilesDbContext { }
public class FilesDbContext : BaseDbContext
2019-12-09 11:59:22 +00:00
{
2022-02-15 11:52:43 +00:00
public DbSet<FilesConverts> FilesConverts { get; set; }
2022-02-15 11:52:43 +00:00
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
{
get
2020-10-06 11:38:15 +00:00
{
2022-02-15 11:52:43 +00:00
return new Dictionary<Provider, Func<BaseDbContext>>()
2020-10-06 11:38:15 +00:00
{
2022-02-15 11:52:43 +00:00
{ Provider.MySql, () => new MySqlFilesDbContext() } ,
{ Provider.PostgreSql, () => new PostgreSqlFilesDbContext() } ,
};
2019-12-09 11:59:22 +00:00
}
}
2022-02-15 11:52:43 +00:00
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
ModelBuilderWrapper
.From(modelBuilder, Provider)
.AddFilesConverts();
}
}
2019-12-09 11:59:22 +00:00
2022-02-15 11:52:43 +00:00
public static class FilesDbExtension
{
public static DIHelper AddFilesDbContextService(this DIHelper services)
2019-12-09 11:59:22 +00:00
{
2022-02-15 11:52:43 +00:00
return services.AddDbContextManagerService<FilesDbContext>();
2019-12-09 11:59:22 +00:00
}
}