支持 abpvnex #37并且发布x.3.1.09
This commit is contained in:
parent
27cc2957ab
commit
fe99a129fe
|
@ -1,8 +1,8 @@
|
||||||
:start
|
:start
|
||||||
::定义版本
|
::定义版本
|
||||||
set EFCORE2=2.3.1.08
|
set EFCORE2=2.3.1.09
|
||||||
set EFCORE3=3.3.1.08
|
set EFCORE3=3.3.1.09
|
||||||
set EFCORE5=5.3.1.08
|
set EFCORE5=5.3.1.09
|
||||||
|
|
||||||
::删除所有bin与obj下的文件
|
::删除所有bin与obj下的文件
|
||||||
@echo off
|
@echo off
|
||||||
|
|
|
@ -66,9 +66,9 @@ namespace Samples.AbpSharding
|
||||||
public DbContext GetDbContext(string dataSourceName, bool parallelQuery, IRouteTail routeTail)
|
public DbContext GetDbContext(string dataSourceName, bool parallelQuery, IRouteTail routeTail)
|
||||||
{
|
{
|
||||||
var dbContext = _shardingDbContextExecutor.CreateDbContext(parallelQuery, dataSourceName, routeTail);
|
var dbContext = _shardingDbContextExecutor.CreateDbContext(parallelQuery, dataSourceName, routeTail);
|
||||||
if (!parallelQuery && dbContext is AbstractShardingAbpDbContext<TDbContext> abstractShardingAbpDbContext)
|
if (!parallelQuery && dbContext is AbpDbContext<TDbContext> abpDbContext)
|
||||||
{
|
{
|
||||||
abstractShardingAbpDbContext.LazyServiceProvider = this.LazyServiceProvider;
|
abpDbContext.LazyServiceProvider = this.LazyServiceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dbContext;
|
return dbContext;
|
||||||
|
@ -83,8 +83,15 @@ namespace Samples.AbpSharding
|
||||||
public DbContext CreateGenericDbContext<TEntity>(TEntity entity) where TEntity : class
|
public DbContext CreateGenericDbContext<TEntity>(TEntity entity) where TEntity : class
|
||||||
{
|
{
|
||||||
CheckAndSetShardingKeyThatSupportAutoCreate(entity);
|
CheckAndSetShardingKeyThatSupportAutoCreate(entity);
|
||||||
return _shardingDbContextExecutor.CreateGenericDbContext(entity);
|
var dbContext = _shardingDbContextExecutor.CreateGenericDbContext(entity);
|
||||||
|
if (dbContext is AbpDbContext<TDbContext> abpDbContext && abpDbContext.LazyServiceProvider == null)
|
||||||
|
{
|
||||||
|
abpDbContext.LazyServiceProvider = this.LazyServiceProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dbContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void CheckAndSetShardingKeyThatSupportAutoCreate<TEntity>(TEntity entity) where TEntity : class
|
private void CheckAndSetShardingKeyThatSupportAutoCreate<TEntity>(TEntity entity) where TEntity : class
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using ShardingCore.Extensions;
|
using ShardingCore.Extensions;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using ShardingCore.Sharding.MergeEngines.ParallelControl;
|
||||||
|
|
||||||
namespace ShardingCore
|
namespace ShardingCore
|
||||||
{
|
{
|
||||||
|
@ -13,6 +14,7 @@ namespace ShardingCore
|
||||||
public class ShardingBootstrapper : IShardingBootstrapper
|
public class ShardingBootstrapper : IShardingBootstrapper
|
||||||
{
|
{
|
||||||
private readonly IEnumerable<IShardingConfigOption> _shardingConfigOptions;
|
private readonly IEnumerable<IShardingConfigOption> _shardingConfigOptions;
|
||||||
|
private readonly DoOnlyOnce _doOnlyOnce = new DoOnlyOnce();
|
||||||
|
|
||||||
public ShardingBootstrapper(IServiceProvider serviceProvider)
|
public ShardingBootstrapper(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
|
@ -22,6 +24,8 @@ namespace ShardingCore
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
|
if (!_doOnlyOnce.IsUnDo())
|
||||||
|
return;
|
||||||
foreach (var shardingConfigOption in _shardingConfigOptions)
|
foreach (var shardingConfigOption in _shardingConfigOptions)
|
||||||
{
|
{
|
||||||
var instance = (IShardingDbContextBootstrapper)Activator.CreateInstance(typeof(ShardingDbContextBootstrapper<>).GetGenericType0(shardingConfigOption.ShardingDbContextType), shardingConfigOption);
|
var instance = (IShardingDbContextBootstrapper)Activator.CreateInstance(typeof(ShardingDbContextBootstrapper<>).GetGenericType0(shardingConfigOption.ShardingDbContextType), shardingConfigOption);
|
||||||
|
|
Loading…
Reference in New Issue