发布x.3.1.87优化动态分库

This commit is contained in:
xuejiaming 2021-12-17 12:45:44 +08:00
parent 8d01cba407
commit e14fee293a
6 changed files with 12 additions and 16 deletions

View File

@ -1,9 +1,9 @@
:start :start
::定义版本 ::定义版本
set EFCORE2=2.3.1.86 set EFCORE2=2.3.1.87
set EFCORE3=3.3.1.86 set EFCORE3=3.3.1.87
set EFCORE5=5.3.1.86 set EFCORE5=5.3.1.87
set EFCORE6=6.3.1.86 set EFCORE6=6.3.1.87
::删除所有bin与obj下的文件 ::删除所有bin与obj下的文件
@echo off @echo off

View File

@ -23,11 +23,13 @@ namespace Sample.SqlServerShardingAll.Controllers
public async Task<IActionResult> Query() public async Task<IActionResult> Query()
{ {
#region #region
//var virtualDataSource = ShardingContainer.GetService<IVirtualDataSource<MyDbContext>>(); var virtualDataSource = ShardingContainer.GetService<IVirtualDataSource<MyDbContext>>();
//var virtualDataSourceRoute = virtualDataSource.GetRoute(typeof(Order)); var virtualDataSourceRoute1 = virtualDataSource.GetRoute(typeof(Order));
//virtualDataSourceRoute.AddDataSourceName("D"); virtualDataSourceRoute1.AddDataSourceName("D");
//DynamicDataSourceHelper.DynamicAppendDataSource<MyDbContext>("D", "连接字符串"); var virtualDataSourceRoute2 = virtualDataSource.GetRoute(typeof(SysUser));
virtualDataSourceRoute2.AddDataSourceName("D");
DynamicDataSourceHelper.DynamicAppendDataSource<MyDbContext>("D", "连接字符串");
#endregion #endregion
var sysUser =await _myDbContext.Set<SysUser>().Where(o=>o.Id=="1").FirstOrDefaultAsync(); var sysUser =await _myDbContext.Set<SysUser>().Where(o=>o.Id=="1").FirstOrDefaultAsync();

View File

@ -148,7 +148,7 @@ namespace ShardingCore.Bootstrapers
{ {
var dataSourceName = dataSourceKv.Key; var dataSourceName = dataSourceKv.Key;
var connectionString = dataSourceKv.Value; var connectionString = dataSourceKv.Value;
_dataSourceInitializer.InitConfigure(dataSourceName, connectionString); _dataSourceInitializer.InitConfigure(dataSourceName, connectionString, _shardingConfigOption.EnsureCreatedWithOutShardingTable);
} }
} }
} }

View File

@ -52,10 +52,6 @@ namespace ShardingCore.DynamicDataSources
_virtualDataSource = virtualDataSource; _virtualDataSource = virtualDataSource;
_logger = logger; _logger = logger;
} }
public void InitConfigure(string dataSourceName, string connectionString)
{
InitConfigure(dataSourceName,connectionString, true);
}
public void InitConfigure(string dataSourceName, string connectionString, bool createDatabase) public void InitConfigure(string dataSourceName, string connectionString, bool createDatabase)
{ {

View File

@ -14,7 +14,7 @@ namespace ShardingCore.DynamicDataSources
public static void DynamicAppendDataSource<TShardingDbContext>(string dataSourceName, string connectionString) where TShardingDbContext:DbContext,IShardingDbContext public static void DynamicAppendDataSource<TShardingDbContext>(string dataSourceName, string connectionString) where TShardingDbContext:DbContext,IShardingDbContext
{ {
var defaultDataSourceInitializer = ShardingContainer.GetService<IDataSourceInitializer<TShardingDbContext>>(); var defaultDataSourceInitializer = ShardingContainer.GetService<IDataSourceInitializer<TShardingDbContext>>();
defaultDataSourceInitializer.InitConfigure(dataSourceName, connectionString); defaultDataSourceInitializer.InitConfigure(dataSourceName, connectionString,true);
} }
} }

View File

@ -10,8 +10,6 @@ namespace ShardingCore.DynamicDataSources
{ {
public interface IDataSourceInitializer<TShardingDbContext> where TShardingDbContext : DbContext, IShardingDbContext public interface IDataSourceInitializer<TShardingDbContext> where TShardingDbContext : DbContext, IShardingDbContext
{ {
[Obsolete("plz use method InitConfigure(string dataSourceName, string connectionString,bool createDatabase)")]
void InitConfigure(string dataSourceName, string connectionString);
void InitConfigure(string dataSourceName, string connectionString,bool createDatabase); void InitConfigure(string dataSourceName, string connectionString,bool createDatabase);
} }
} }