Skip to content

Commit

Permalink
发布x.6.0.1版本
Browse files Browse the repository at this point in the history
  • Loading branch information
xuejmnet committed Jul 6, 2022
1 parent 7148d7c commit fb1c2cf
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
11 changes: 6 additions & 5 deletions benchmarks/ShardingCoreBenchmark/EFCoreCrud.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ public class EFCoreCrud
{
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()))
Expand All @@ -25,11 +26,11 @@ public EFCoreCrud()
services.AddLogging();

services.AddShardingDbContext<DefaultShardingDbContext>(ServiceLifetime.Transient, ServiceLifetime.Transient)
.AddEntityConfig(o =>
.UseRouteConfig(o =>
{
o.AddShardingTableRoute<OrderVirtualTableRoute>();
})
.AddConfig(op =>
.UseConfig(op =>
{
op.UseShardingQuery((conStr, builder) =>
{
Expand All @@ -44,9 +45,9 @@ public EFCoreCrud()
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
8 changes: 4 additions & 4 deletions nuget-publish.bat
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 4 additions & 3 deletions samples/Samples.AbpSharding/AbstractShardingAbpDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Reflection;
using ShardingCore.Core.VirtualDatabase.VirtualDataSources;
using ShardingCore.Sharding;

namespace Samples.AbpSharding
{
Expand Down Expand Up @@ -63,10 +64,10 @@ public bool ReadWriteSeparation
// //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;
}
Expand Down
4 changes: 2 additions & 2 deletions test/ShardingCore.Test3x/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public void ConfigureServices(IServiceCollection services, HostBuilderContext ho
services.AddShardingDbContext<ShardingDefaultDbContext>()
.UseRouteConfig(op =>
{
//当无法获取路由时会返回默认值而不是报错
op.ThrowIfQueryRouteNotMatch = false;
op.AddShardingDataSourceRoute<OrderAreaShardingVirtualDataSourceRoute>();
op.AddShardingTableRoute<SysUserModVirtualTableRoute>();
op.AddShardingTableRoute<SysUserSalaryVirtualTableRoute>();
Expand All @@ -57,6 +55,8 @@ public void ConfigureServices(IServiceCollection services, HostBuilderContext ho
})
.UseConfig(op =>
{
//当无法获取路由时会返回默认值而不是报错
op.ThrowIfQueryRouteNotMatch = false;
op.UseShardingQuery((conStr, builder) =>
{
builder.UseSqlServer(conStr).UseLoggerFactory(efLogger);
Expand Down
4 changes: 2 additions & 2 deletions test/ShardingCore.Test5x/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public void ConfigureServices(IServiceCollection services, HostBuilderContext ho
services.AddShardingDbContext<ShardingDefaultDbContext>()
.UseRouteConfig(op =>
{
//当无法获取路由时会返回默认值而不是报错
op.ThrowIfQueryRouteNotMatch = false;
op.AddShardingDataSourceRoute<OrderAreaShardingVirtualDataSourceRoute>();
op.AddShardingTableRoute<SysUserModVirtualTableRoute>();
op.AddShardingTableRoute<SysUserSalaryVirtualTableRoute>();
Expand All @@ -57,6 +55,8 @@ public void ConfigureServices(IServiceCollection services, HostBuilderContext ho
})
.UseConfig(op =>
{
//当无法获取路由时会返回默认值而不是报错
op.ThrowIfQueryRouteNotMatch = false;
op.UseShardingQuery((conStr, builder) =>
{
Expand Down

0 comments on commit fb1c2cf

Please sign in to comment.