2019-12-17 13:01:59 +00:00
|
|
|
|
|
2020-10-19 15:53:15 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2020-09-06 22:49:03 +00:00
|
|
|
|
using ASC.Core.Common.EF.Model;
|
2020-10-12 16:23:15 +00:00
|
|
|
|
|
2019-12-17 13:01:59 +00:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2020-10-12 16:23:15 +00:00
|
|
|
|
|
2019-11-29 12:26:53 +00:00
|
|
|
|
namespace ASC.Core.Common.EF
|
|
|
|
|
{
|
2020-10-06 11:38:15 +00:00
|
|
|
|
public class MySqlCoreDbContext : CoreDbContext { }
|
|
|
|
|
public class PostgreSqlCoreDbContext : CoreDbContext { }
|
2019-11-29 12:26:53 +00:00
|
|
|
|
public class CoreDbContext : BaseDbContext
|
|
|
|
|
{
|
2019-12-02 12:22:40 +00:00
|
|
|
|
public DbSet<DbTariff> Tariffs { get; set; }
|
|
|
|
|
public DbSet<DbButton> Buttons { get; set; }
|
2019-12-02 09:12:16 +00:00
|
|
|
|
public DbSet<DbQuota> Quotas { get; set; }
|
|
|
|
|
public DbSet<DbQuotaRow> QuotaRows { get; set; }
|
2020-10-06 11:38:15 +00:00
|
|
|
|
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
|
2019-12-17 08:27:38 +00:00
|
|
|
|
{
|
2020-10-06 11:38:15 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return new Dictionary<Provider, Func<BaseDbContext>>()
|
|
|
|
|
{
|
|
|
|
|
{ Provider.MySql, () => new MySqlCoreDbContext() } ,
|
2021-10-12 10:23:20 +00:00
|
|
|
|
{ Provider.PostgreSql, () => new PostgreSqlCoreDbContext() } ,
|
2020-10-06 11:38:15 +00:00
|
|
|
|
};
|
2020-10-12 16:23:15 +00:00
|
|
|
|
}
|
2019-12-17 08:27:38 +00:00
|
|
|
|
}
|
2019-11-29 12:26:53 +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)
|
2019-12-17 13:01:59 +00:00
|
|
|
|
.AddDbButton()
|
2020-09-06 22:49:03 +00:00
|
|
|
|
.AddDbQuotaRow()
|
|
|
|
|
.AddDbQuota()
|
2020-10-05 10:02:28 +00:00
|
|
|
|
.AddDbTariff();
|
2019-11-29 12:26:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|