Skip to content

Commit fe99a12

Browse files
committed
支持 abpvnex #37并且发布x.3.1.09
1 parent 27cc295 commit fe99a12

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

nuget-publish.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
:start
22
::定义版本
3-
set EFCORE2=2.3.1.08
4-
set EFCORE3=3.3.1.08
5-
set EFCORE5=5.3.1.08
3+
set EFCORE2=2.3.1.09
4+
set EFCORE3=3.3.1.09
5+
set EFCORE5=5.3.1.09
66

77
::删除所有bin与obj下的文件
88
@echo off

samples/Samples.AbpSharding/AbstractShardingAbpDbContext.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ public bool ReadWriteSeparation
6666
public DbContext GetDbContext(string dataSourceName, bool parallelQuery, IRouteTail routeTail)
6767
{
6868
var dbContext = _shardingDbContextExecutor.CreateDbContext(parallelQuery, dataSourceName, routeTail);
69-
if (!parallelQuery && dbContext is AbstractShardingAbpDbContext<TDbContext> abstractShardingAbpDbContext)
69+
if (!parallelQuery && dbContext is AbpDbContext<TDbContext> abpDbContext)
7070
{
71-
abstractShardingAbpDbContext.LazyServiceProvider = this.LazyServiceProvider;
71+
abpDbContext.LazyServiceProvider = this.LazyServiceProvider;
7272
}
7373

7474
return dbContext;
@@ -83,8 +83,15 @@ public DbContext GetDbContext(string dataSourceName, bool parallelQuery, IRouteT
8383
public DbContext CreateGenericDbContext<TEntity>(TEntity entity) where TEntity : class
8484
{
8585
CheckAndSetShardingKeyThatSupportAutoCreate(entity);
86-
return _shardingDbContextExecutor.CreateGenericDbContext(entity);
86+
var dbContext = _shardingDbContextExecutor.CreateGenericDbContext(entity);
87+
if (dbContext is AbpDbContext<TDbContext> abpDbContext && abpDbContext.LazyServiceProvider == null)
88+
{
89+
abpDbContext.LazyServiceProvider = this.LazyServiceProvider;
90+
}
91+
92+
return dbContext;
8793
}
94+
8895

8996
private void CheckAndSetShardingKeyThatSupportAutoCreate<TEntity>(TEntity entity) where TEntity : class
9097
{

src/ShardingCore/ShardingBootstrapper.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using ShardingCore.Extensions;
22
using System;
33
using System.Collections.Generic;
4+
using ShardingCore.Sharding.MergeEngines.ParallelControl;
45

56
namespace ShardingCore
67
{
@@ -13,6 +14,7 @@ namespace ShardingCore
1314
public class ShardingBootstrapper : IShardingBootstrapper
1415
{
1516
private readonly IEnumerable<IShardingConfigOption> _shardingConfigOptions;
17+
private readonly DoOnlyOnce _doOnlyOnce = new DoOnlyOnce();
1618

1719
public ShardingBootstrapper(IServiceProvider serviceProvider)
1820
{
@@ -22,6 +24,8 @@ public ShardingBootstrapper(IServiceProvider serviceProvider)
2224

2325
public void Start()
2426
{
27+
if (!_doOnlyOnce.IsUnDo())
28+
return;
2529
foreach (var shardingConfigOption in _shardingConfigOptions)
2630
{
2731
var instance = (IShardingDbContextBootstrapper)Activator.CreateInstance(typeof(ShardingDbContextBootstrapper<>).GetGenericType0(shardingConfigOption.ShardingDbContextType), shardingConfigOption);

0 commit comments

Comments
 (0)