DocSpace-client/common/ASC.Core.Common/EF/Context/NotifyDbContext.cs
2020-11-17 13:00:01 +03:00

45 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using ASC.Common;
using ASC.Core.Common.EF.Model;
using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Context
{
public class MySqlNotifyDbContext : NotifyDbContext { }
public class PostgreSqlNotifyDbContext : NotifyDbContext { }
public class NotifyDbContext : BaseDbContext
{
public DbSet<NotifyInfo> NotifyInfo { get; set; }
public DbSet<NotifyQueue> NotifyQueue { get; set; }
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
{
get
{
return new Dictionary<Provider, Func<BaseDbContext>>()
{
{ Provider.MySql, () => new MySqlNotifyDbContext() } ,
{ Provider.Postgre, () => new PostgreSqlNotifyDbContext() } ,
};
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
ModelBuilderWrapper
.From(modelBuilder, Provider)
.AddNotifyInfo()
.AddNotifyQueue();
}
}
public static class NotifyDbExtension
{
public static DIHelper AddNotifyDbContext(this DIHelper services)
{
return services.AddDbContextManagerService<NotifyDbContext>();
}
}
}