DocSpace-client/common/ASC.Core.Common/EF/Context/AccountLinkContext.cs

45 lines
1.3 KiB
C#
Raw Normal View History

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-04 11:40:42 +00:00
using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Context
{
2020-10-06 11:38:15 +00:00
public class MySqlAccountLinkContext : AccountLinkContext { }
public class PostgreSqlAccountLinkContext : AccountLinkContext { }
public class AccountLinkContext : BaseDbContext
2019-12-04 11:40:42 +00:00
{
public DbSet<AccountLinks> AccountLinks { 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 MySqlAccountLinkContext() } ,
2020-10-08 09:07:05 +00:00
{ Provider.Postgre, () => new PostgreSqlAccountLinkContext() } ,
2020-10-06 11:38:15 +00:00
};
}
}
2019-12-04 11:40:42 +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
.AddAccountLinks();
2019-12-04 11:40:42 +00:00
}
}
public static class AccountLinkContextExtension
{
2020-02-17 08:58:14 +00:00
public static DIHelper AddAccountLinkContextService(this DIHelper services)
2019-12-04 11:40:42 +00:00
{
2019-12-10 15:06:51 +00:00
return services.AddDbContextManagerService<AccountLinkContext>();
2019-12-04 11:40:42 +00:00
}
}
}