mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-05-06 21:58:05 +08:00
Merge branch 'main' of https://gitee.com/dotnetchina/OpenAuth.Net
This commit is contained in:
commit
fb8f6ebb7e
@ -1,33 +1,29 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using Infrastructure;
|
||||
using Infrastructure.Extensions;
|
||||
using Infrastructure.Utilities;
|
||||
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using OpenAuth.Repository.Domain;
|
||||
using OpenAuth.Repository.QueryObj;
|
||||
|
||||
namespace OpenAuth.Repository
|
||||
{
|
||||
|
||||
public partial class OpenAuthDBContext : DbContext
|
||||
{
|
||||
|
||||
private ILoggerFactory _LoggerFactory;
|
||||
private IHttpContextAccessor _httpContextAccessor;
|
||||
private IConfiguration _configuration;
|
||||
private IOptions<AppSetting> _appConfiguration;
|
||||
|
||||
public OpenAuthDBContext(DbContextOptions<OpenAuthDBContext> options, ILoggerFactory loggerFactory,
|
||||
IHttpContextAccessor httpContextAccessor, IConfiguration configuration, IOptions<AppSetting> appConfiguration)
|
||||
IHttpContextAccessor httpContextAccessor, IConfiguration configuration,
|
||||
IOptions<AppSetting> appConfiguration)
|
||||
: base(options)
|
||||
{
|
||||
_LoggerFactory = loggerFactory;
|
||||
@ -47,7 +43,6 @@ namespace OpenAuth.Repository
|
||||
//初始化多租户信息,根据租户id调整数据库
|
||||
private void InitTenant(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
|
||||
var tenantId = _httpContextAccessor.GetTenantId();
|
||||
string connect = _configuration.GetConnectionString(tenantId);
|
||||
if (string.IsNullOrEmpty(connect))
|
||||
@ -76,7 +71,6 @@ namespace OpenAuth.Repository
|
||||
{
|
||||
optionsBuilder.UseOracle(connect, options => options.UseOracleSQLCompatibility("11"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
@ -87,7 +81,8 @@ namespace OpenAuth.Repository
|
||||
modelBuilder.Entity<QueryStringObj>().HasNoKey();
|
||||
|
||||
//converting between PostgreSQL smallint and .NET Boolean types
|
||||
if (Database.ProviderName == "Npgsql.EntityFrameworkCore.PostgreSQL")
|
||||
if (Database.ProviderName == "Npgsql.EntityFrameworkCore.PostgreSQL"
|
||||
|| Database.ProviderName == "Oracle.EntityFrameworkCore")
|
||||
{
|
||||
var boolToSmallIntConverter = new ValueConverter<bool, short>(
|
||||
v => v ? (short) 1 : (short) 0,
|
||||
@ -103,10 +98,6 @@ namespace OpenAuth.Repository
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public virtual DbSet<Application> Applications { get; set; }
|
||||
@ -135,13 +126,11 @@ namespace OpenAuth.Repository
|
||||
public virtual DbSet<WmsInboundOrderTbl> WmsInboundOrderTbls { get; set; }
|
||||
public virtual DbSet<OpenJob> OpenJobs { get; set; }
|
||||
public virtual DbSet<BuilderTable> BuilderTables { get; set; }
|
||||
|
||||
public virtual DbSet<BuilderTableColumn> BuilderTableColumns { get; set; }
|
||||
|
||||
//非数据库表格
|
||||
public virtual DbSet<QueryStringObj> QueryStringObjs { get; set; }
|
||||
public virtual DbSet<SysTableColumn> SysTableColumns { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user