2020-10-09 15:52:17 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
using ASC.Common;
|
2020-02-17 08:58:14 +00:00
|
|
|
|
using ASC.Core.Common.EF.Model;
|
2020-10-09 15:52:17 +00:00
|
|
|
|
|
2019-12-09 11:59:22 +00:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
namespace ASC.Core.Common.EF.Context
|
|
|
|
|
{
|
2020-10-06 11:38:15 +00:00
|
|
|
|
public class MySqlFilesDbContext : FilesDbContext { }
|
|
|
|
|
public class PostgreSqlFilesDbContext : FilesDbContext { }
|
2020-10-05 09:27:15 +00:00
|
|
|
|
public class FilesDbContext : BaseDbContext
|
2019-12-09 11:59:22 +00:00
|
|
|
|
{
|
|
|
|
|
public DbSet<FilesConverts> FilesConverts { get; set; }
|
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 MySqlFilesDbContext() } ,
|
2021-10-12 10:23:20 +00:00
|
|
|
|
{ Provider.PostgreSql, () => new PostgreSqlFilesDbContext() } ,
|
2020-10-06 11:38:15 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-09 11:59:22 +00:00
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
2020-10-12 19:39:23 +00:00
|
|
|
|
ModelBuilderWrapper
|
2020-09-06 22:49:03 +00:00
|
|
|
|
.From(modelBuilder, Provider)
|
2020-10-05 10:02:28 +00:00
|
|
|
|
.AddFilesConverts();
|
2019-12-09 11:59:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class FilesDbExtension
|
|
|
|
|
{
|
2020-02-17 08:58:14 +00:00
|
|
|
|
public static DIHelper AddFilesDbContextService(this DIHelper services)
|
2019-12-09 11:59:22 +00:00
|
|
|
|
{
|
2019-12-10 15:06:51 +00:00
|
|
|
|
return services.AddDbContextManagerService<FilesDbContext>();
|
2019-12-09 11:59:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|