发布x.6.0.1版本
This commit is contained in:
parent
7148d7c5b7
commit
fb1c2cfdd7
|
@ -14,9 +14,10 @@ namespace ShardingCore6x
|
|||
{
|
||||
private readonly DefaultDbContext _defaultDbContext;
|
||||
private readonly DefaultShardingDbContext _defaultShardingDbContext;
|
||||
private readonly ServiceCollection services;
|
||||
public EFCoreCrud()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services = new ServiceCollection();
|
||||
|
||||
services.AddDbContext<DefaultDbContext>(o => o
|
||||
//.UseMySql("server=127.0.0.1;port=3306;database=db1;userid=root;password=L6yBtV6qNENrwBy7;", new MySqlServerVersion(new Version()))
|
||||
|
@ -25,11 +26,11 @@ namespace ShardingCore6x
|
|||
services.AddLogging();
|
||||
|
||||
services.AddShardingDbContext<DefaultShardingDbContext>(ServiceLifetime.Transient, ServiceLifetime.Transient)
|
||||
.AddEntityConfig(o =>
|
||||
.UseRouteConfig(o =>
|
||||
{
|
||||
o.AddShardingTableRoute<OrderVirtualTableRoute>();
|
||||
})
|
||||
.AddConfig(op =>
|
||||
.UseConfig(op =>
|
||||
{
|
||||
op.UseShardingQuery((conStr, builder) =>
|
||||
{
|
||||
|
@ -44,9 +45,9 @@ namespace ShardingCore6x
|
|||
op.AddDefaultDataSource("ds0",
|
||||
"Data Source=localhost;Initial Catalog=db2;Integrated Security=True;");
|
||||
|
||||
//op.AddDefaultDataSource("ds0", "server=127.0.0.1;port=3306;database=db2;userid=root;password=L6yBtV6qNENrwBy7;")
|
||||
//op.AddDefaultDataSource("ds0", "server=127.0.0.1;port=3306;database=db2;userid=root;password=L6yBtV6qNENrwBy7;");
|
||||
|
||||
}).EnsureConfig();
|
||||
}).AddShardingCore();
|
||||
|
||||
var buildServiceProvider = services.BuildServiceProvider();
|
||||
buildServiceProvider.UseAutoShardingCreate();
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<PackageReference Include="EFCore.BulkExtensions" Version="6.1.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.1" />
|
||||
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="6.13.8" />
|
||||
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="6.14.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
:start
|
||||
::定义版本
|
||||
set EFCORE2=2.6.0.1-preview0.0.4
|
||||
set EFCORE3=3.6.0.1-preview0.0.4
|
||||
set EFCORE5=5.6.0.1-preview0.0.4
|
||||
set EFCORE6=6.6.0.1-preview0.0.4
|
||||
set EFCORE2=2.6.0.1
|
||||
set EFCORE3=3.6.0.1
|
||||
set EFCORE5=5.6.0.1
|
||||
set EFCORE6=6.6.0.1
|
||||
|
||||
::删除所有bin与obj下的文件
|
||||
@echo off
|
||||
|
|
|
@ -17,6 +17,7 @@ using Volo.Abp.Domain.Entities;
|
|||
using Volo.Abp.EntityFrameworkCore;
|
||||
using Volo.Abp.Reflection;
|
||||
using ShardingCore.Core.VirtualDatabase.VirtualDataSources;
|
||||
using ShardingCore.Sharding;
|
||||
|
||||
namespace Samples.AbpSharding
|
||||
{
|
||||
|
@ -63,10 +64,10 @@ namespace Samples.AbpSharding
|
|||
// //IsExecutor = true;
|
||||
//}
|
||||
|
||||
public DbContext GetDbContext(string dataSourceName, bool parallelQuery, IRouteTail routeTail)
|
||||
public DbContext GetDbContext(string dataSourceName, CreateDbContextStrategyEnum strategy, IRouteTail routeTail)
|
||||
{
|
||||
var dbContext = _shardingDbContextExecutor.CreateDbContext(parallelQuery, dataSourceName, routeTail);
|
||||
if (!parallelQuery && dbContext is AbpDbContext<TDbContext> abpDbContext)
|
||||
var dbContext = _shardingDbContextExecutor.CreateDbContext(strategy, dataSourceName, routeTail);
|
||||
if (dbContext is AbpDbContext<TDbContext> abpDbContext)
|
||||
{
|
||||
abpDbContext.LazyServiceProvider = this.LazyServiceProvider;
|
||||
}
|
||||
|
|
|
@ -38,8 +38,6 @@ namespace ShardingCore.Test3x
|
|||
services.AddShardingDbContext<ShardingDefaultDbContext>()
|
||||
.UseRouteConfig(op =>
|
||||
{
|
||||
//当无法获取路由时会返回默认值而不是报错
|
||||
op.ThrowIfQueryRouteNotMatch = false;
|
||||
op.AddShardingDataSourceRoute<OrderAreaShardingVirtualDataSourceRoute>();
|
||||
op.AddShardingTableRoute<SysUserModVirtualTableRoute>();
|
||||
op.AddShardingTableRoute<SysUserSalaryVirtualTableRoute>();
|
||||
|
@ -57,6 +55,8 @@ namespace ShardingCore.Test3x
|
|||
})
|
||||
.UseConfig(op =>
|
||||
{
|
||||
//当无法获取路由时会返回默认值而不是报错
|
||||
op.ThrowIfQueryRouteNotMatch = false;
|
||||
op.UseShardingQuery((conStr, builder) =>
|
||||
{
|
||||
builder.UseSqlServer(conStr).UseLoggerFactory(efLogger);
|
||||
|
|
|
@ -38,8 +38,6 @@ namespace ShardingCore.Test5x
|
|||
services.AddShardingDbContext<ShardingDefaultDbContext>()
|
||||
.UseRouteConfig(op =>
|
||||
{
|
||||
//当无法获取路由时会返回默认值而不是报错
|
||||
op.ThrowIfQueryRouteNotMatch = false;
|
||||
op.AddShardingDataSourceRoute<OrderAreaShardingVirtualDataSourceRoute>();
|
||||
op.AddShardingTableRoute<SysUserModVirtualTableRoute>();
|
||||
op.AddShardingTableRoute<SysUserSalaryVirtualTableRoute>();
|
||||
|
@ -57,6 +55,8 @@ namespace ShardingCore.Test5x
|
|||
})
|
||||
.UseConfig(op =>
|
||||
{
|
||||
//当无法获取路由时会返回默认值而不是报错
|
||||
op.ThrowIfQueryRouteNotMatch = false;
|
||||
|
||||
op.UseShardingQuery((conStr, builder) =>
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue