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

37 lines
1.2 KiB
C#
Raw Normal View History

namespace ASC.Core.Common.EF.Context
2019-12-10 13:42:29 +00:00
{
2020-10-06 11:38:15 +00:00
public class MySqlNotifyDbContext : NotifyDbContext { }
public class PostgreSqlNotifyDbContext : NotifyDbContext { }
public class NotifyDbContext : BaseDbContext
2019-12-10 13:42:29 +00:00
{
public DbSet<NotifyInfo> NotifyInfo { get; set; }
public DbSet<NotifyQueue> NotifyQueue { 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 MySqlNotifyDbContext() } ,
2021-10-12 10:23:20 +00:00
{ Provider.PostgreSql, () => new PostgreSqlNotifyDbContext() } ,
2020-10-06 11:38:15 +00:00
};
}
}
2020-08-21 02:34:37 +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)
.AddNotifyInfo()
2020-10-05 10:02:28 +00:00
.AddNotifyQueue();
2020-08-21 02:34:37 +00:00
}
2019-12-10 13:42:29 +00:00
}
public static class NotifyDbExtension
{
2020-02-17 08:58:14 +00:00
public static DIHelper AddNotifyDbContext(this DIHelper services)
2019-12-10 13:42:29 +00:00
{
2019-12-10 15:06:51 +00:00
return services.AddDbContextManagerService<NotifyDbContext>();
2019-12-10 13:42:29 +00:00
}
}
}