支持 abpvnex #37并且发布x.3.1.09

This commit is contained in:
xuejiaming 2021-10-23 17:00:25 +08:00
parent 27cc2957ab
commit fe99a129fe
3 changed files with 17 additions and 6 deletions

View File

@ -1,8 +1,8 @@
:start
::定义版本
set EFCORE2=2.3.1.08
set EFCORE3=3.3.1.08
set EFCORE5=5.3.1.08
set EFCORE2=2.3.1.09
set EFCORE3=3.3.1.09
set EFCORE5=5.3.1.09
::删除所有bin与obj下的文件
@echo off

View File

@ -66,9 +66,9 @@ namespace Samples.AbpSharding
public DbContext GetDbContext(string dataSourceName, bool parallelQuery, IRouteTail 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;
@ -83,9 +83,16 @@ namespace Samples.AbpSharding
public DbContext CreateGenericDbContext<TEntity>(TEntity entity) where TEntity : class
{
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
{
if (entity is IShardingKeyIsGuId)

View File

@ -1,6 +1,7 @@
using ShardingCore.Extensions;
using System;
using System.Collections.Generic;
using ShardingCore.Sharding.MergeEngines.ParallelControl;
namespace ShardingCore
{
@ -13,6 +14,7 @@ namespace ShardingCore
public class ShardingBootstrapper : IShardingBootstrapper
{
private readonly IEnumerable<IShardingConfigOption> _shardingConfigOptions;
private readonly DoOnlyOnce _doOnlyOnce = new DoOnlyOnce();
public ShardingBootstrapper(IServiceProvider serviceProvider)
{
@ -22,6 +24,8 @@ namespace ShardingCore
public void Start()
{
if (!_doOnlyOnce.IsUnDo())
return;
foreach (var shardingConfigOption in _shardingConfigOptions)
{
var instance = (IShardingDbContextBootstrapper)Activator.CreateInstance(typeof(ShardingDbContextBootstrapper<>).GetGenericType0(shardingConfigOption.ShardingDbContextType), shardingConfigOption);