优化聚合升级到7.x.1.8
This commit is contained in:
parent
25d562e045
commit
592a5016d8
|
@ -1,10 +1,10 @@
|
||||||
:start
|
:start
|
||||||
::定义版本
|
::定义版本
|
||||||
set EFCORE7=7.7.1.7
|
set EFCORE7=7.7.1.8
|
||||||
set EFCORE6=7.6.1.7
|
set EFCORE6=7.6.1.8
|
||||||
set EFCORE5=7.5.1.7
|
set EFCORE5=7.5.1.8
|
||||||
set EFCORE3=7.3.1.7
|
set EFCORE3=7.3.1.8
|
||||||
set EFCORE2=7.2.1.7
|
set EFCORE2=7.2.1.8
|
||||||
|
|
||||||
::删除所有bin与obj下的文件
|
::删除所有bin与obj下的文件
|
||||||
@echo off
|
@echo off
|
||||||
|
|
|
@ -9,6 +9,7 @@ using ShardingCore.Core.RuntimeContexts;
|
||||||
using ShardingCore.Core.VirtualDatabase.VirtualDataSources.PhysicDataSources;
|
using ShardingCore.Core.VirtualDatabase.VirtualDataSources.PhysicDataSources;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions;
|
||||||
|
using ShardingCore.Extensions;
|
||||||
using ShardingCore.Extensions.ShardingPageExtensions;
|
using ShardingCore.Extensions.ShardingPageExtensions;
|
||||||
using ShardingCore.Extensions.ShardingQueryableExtensions;
|
using ShardingCore.Extensions.ShardingQueryableExtensions;
|
||||||
using ShardingCore.Helpers;
|
using ShardingCore.Helpers;
|
||||||
|
@ -79,7 +80,8 @@ namespace Sample.MySql.Controllers
|
||||||
var dataSourceInitializer = _shardingRuntimeContext.GetDataSourceInitializer();
|
var dataSourceInitializer = _shardingRuntimeContext.GetDataSourceInitializer();
|
||||||
dataSourceInitializer.InitConfigure("ds9",true,true);
|
dataSourceInitializer.InitConfigure("ds9",true,true);
|
||||||
|
|
||||||
|
// _defaultTableDbContext.ReadWriteSeparationReadOnly();//读库
|
||||||
|
// _defaultTableDbContext.ReadWriteSeparationWriteOnly();//写库
|
||||||
var shardingTableCreator = _shardingRuntimeContext.GetShardingTableCreator();
|
var shardingTableCreator = _shardingRuntimeContext.GetShardingTableCreator();
|
||||||
var tableRouteManager = _shardingRuntimeContext.GetTableRouteManager();
|
var tableRouteManager = _shardingRuntimeContext.GetTableRouteManager();
|
||||||
//系统的时间分片都会实现 ITailAppendable 如果不是系统的自定义的转成你自己的对象即可
|
//系统的时间分片都会实现 ITailAppendable 如果不是系统的自定义的转成你自己的对象即可
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace Sample.MySql.DbContexts
|
||||||
modelBuilder.ApplyConfiguration(new SysTestMap());
|
modelBuilder.ApplyConfiguration(new SysTestMap());
|
||||||
modelBuilder.ApplyConfiguration(new SysUserLogByMonthMap());
|
modelBuilder.ApplyConfiguration(new SysUserLogByMonthMap());
|
||||||
|
|
||||||
// modelBuilder.Entity<SysUserLogByMonth>().HasData(new SysUserLogByMonth() { Id = "1", Time = DateTime.Now });
|
modelBuilder.Entity<SysUserLogByMonth>().HasData(new SysUserLogByMonth() { Id = "1", Time = DateTime.Now });
|
||||||
// modelBuilder.Entity<SysTest>().HasData(new SysTest() { Id = "1", UserId = "123" });
|
// modelBuilder.Entity<SysTest>().HasData(new SysTest() { Id = "1", UserId = "123" });
|
||||||
// modelBuilder.Entity<TestMod>().ToTable(nameof(TestMod));
|
// modelBuilder.Entity<TestMod>().ToTable(nameof(TestMod));
|
||||||
// modelBuilder.Entity<SysTest>().ToTable("xxx");
|
// modelBuilder.Entity<SysTest>().ToTable("xxx");
|
||||||
|
|
|
@ -8,5 +8,6 @@
|
||||||
{
|
{
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public string UserId { get; set; }
|
public string UserId { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@ namespace Sample.MySql.Domain.Maps
|
||||||
public void Configure(EntityTypeBuilder<SysUserMod> builder)
|
public void Configure(EntityTypeBuilder<SysUserMod> builder)
|
||||||
{
|
{
|
||||||
builder.HasKey(o => o.Id);
|
builder.HasKey(o => o.Id);
|
||||||
builder.Property(o => o.Id).IsRequired().HasMaxLength(128);
|
builder.Property(o => o.Id).ValueGeneratedNever().IsRequired().HasMaxLength(128);
|
||||||
builder.Property(o => o.Name).HasMaxLength(128);
|
builder.Property(o => o.Name).HasMaxLength(128);
|
||||||
builder.ToTable(nameof(SysUserMod));
|
builder.ToTable(nameof(SysUserMod));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
using Sample.MySql.DbContexts;
|
||||||
|
using ShardingCore.Core.RuntimeContexts;
|
||||||
|
using ShardingCore.Extensions;
|
||||||
|
|
||||||
|
namespace Sample.MySql
|
||||||
|
{
|
||||||
|
|
||||||
|
public class NoReadWriteMiddleware
|
||||||
|
{
|
||||||
|
private readonly RequestDelegate _next;
|
||||||
|
|
||||||
|
public NoReadWriteMiddleware(RequestDelegate next)
|
||||||
|
{
|
||||||
|
_next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Invoke(HttpContext context)
|
||||||
|
{
|
||||||
|
if (context.Request.Path.ToString().StartsWith("/admin"))
|
||||||
|
{
|
||||||
|
var shardingRuntimeContext = context.RequestServices.GetService<IShardingRuntimeContext<DefaultShardingDbContext>>();
|
||||||
|
var shardingReadWriteManager = shardingRuntimeContext.GetShardingReadWriteManager();
|
||||||
|
using (var scope = shardingReadWriteManager.CreateScope())
|
||||||
|
{
|
||||||
|
shardingReadWriteManager.GetCurrent().SetReadWriteSeparation(9999,false);
|
||||||
|
await _next(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _next(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -93,6 +93,7 @@ namespace Sample.MySql
|
||||||
// {
|
// {
|
||||||
// b.UseMemoryCache(memoryCache);
|
// b.UseMemoryCache(memoryCache);
|
||||||
// });
|
// });
|
||||||
|
o.IgnoreCreateTableError = false;
|
||||||
o.UseEntityFrameworkCoreProxies = true;
|
o.UseEntityFrameworkCoreProxies = true;
|
||||||
o.CacheModelLockConcurrencyLevel = 1024;
|
o.CacheModelLockConcurrencyLevel = 1024;
|
||||||
o.CacheEntrySize = 1;
|
o.CacheEntrySize = 1;
|
||||||
|
@ -213,7 +214,6 @@ namespace Sample.MySql
|
||||||
// app.ApplicationServices.UseAutoTryCompensateTable(12);
|
// app.ApplicationServices.UseAutoTryCompensateTable(12);
|
||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
|
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
|
||||||
|
|
|
@ -15,9 +15,7 @@ namespace ShardingCore.Core.VirtualRoutes
|
||||||
|
|
||||||
public ShardingRouteResult(List<ISqlRouteUnit> routeUnits,bool isEmpty,bool isCrossDataSource,bool isCrossTable,bool existCrossTableTails)
|
public ShardingRouteResult(List<ISqlRouteUnit> routeUnits,bool isEmpty,bool isCrossDataSource,bool isCrossTable,bool existCrossTableTails)
|
||||||
{
|
{
|
||||||
var routeUnitGroup = routeUnits.GroupBy(o=>o.DataSourceName);
|
|
||||||
RouteUnits = routeUnits;
|
RouteUnits = routeUnits;
|
||||||
var count = routeUnitGroup.Count();
|
|
||||||
IsEmpty =isEmpty;
|
IsEmpty =isEmpty;
|
||||||
IsCrossDataSource = isCrossDataSource;
|
IsCrossDataSource = isCrossDataSource;
|
||||||
IsCrossTable = isCrossTable;
|
IsCrossTable = isCrossTable;
|
||||||
|
|
|
@ -114,6 +114,7 @@ namespace ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine
|
||||||
var routeResults = routeMap.Select(o => o.Value).Cartesian()
|
var routeResults = routeMap.Select(o => o.Value).Cartesian()
|
||||||
.Select(o => new TableRouteResult(o.ToList())).Where(o => !o.IsEmpty).ToArray();
|
.Select(o => new TableRouteResult(o.ToList())).Where(o => !o.IsEmpty).ToArray();
|
||||||
|
|
||||||
|
//平行表
|
||||||
var tableRouteResults = GetTableRouteResults(tableRouteRuleContext, routeResults);
|
var tableRouteResults = GetTableRouteResults(tableRouteRuleContext, routeResults);
|
||||||
if (tableRouteResults.IsNotEmpty())
|
if (tableRouteResults.IsNotEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,11 @@ namespace ShardingCore.Sharding.MergeEngines.ShardingExecutors
|
||||||
.ToList();
|
.ToList();
|
||||||
if (results.IsEmpty())
|
if (results.IsEmpty())
|
||||||
throw new ShardingCoreException("sharding execute result empty");
|
throw new ShardingCoreException("sharding execute result empty");
|
||||||
|
//不需要merge
|
||||||
|
if (results.Count == 1)
|
||||||
|
{
|
||||||
|
return results[0];
|
||||||
|
}
|
||||||
var streamMerge = executor.GetShardingMerger().StreamMerge(results);
|
var streamMerge = executor.GetShardingMerger().StreamMerge(results);
|
||||||
return streamMerge;
|
return streamMerge;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue