diff --git a/samples/Sample.SqlServer/Controllers/ValuesController.cs b/samples/Sample.SqlServer/Controllers/ValuesController.cs index 0dd0f51b..cba08629 100644 --- a/samples/Sample.SqlServer/Controllers/ValuesController.cs +++ b/samples/Sample.SqlServer/Controllers/ValuesController.cs @@ -11,6 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage; using Microsoft.Extensions.Logging; using Sample.SqlServer.DbContexts; using Sample.SqlServer.Domain.Entities; +using ShardingCore.Core.PhysicTables; using ShardingCore.Core.QueryRouteManagers.Abstractions; using ShardingCore.DbContexts.VirtualDbContexts; using ShardingCore.Extensions; @@ -89,7 +90,9 @@ namespace Sample.SqlServer.Controllers using (_shardingRouteManager.CreateScope()) { - _shardingRouteManager.Current.TryCreateOrAddMustTail("00"); + _shardingRouteManager.Current.TryCreateOrAddMustTail("00","01"); + //_shardingRouteManager.Current.TryCreateOrAddHintTail("00", "01"); + //_shardingRouteManager.Current.TryCreateOrAddAssertTail(new TestRouteAssert()); var mod00s = await _defaultTableDbContext.Set().Skip(10).Take(11).ToListAsync(); } diff --git a/samples/Sample.SqlServer/Shardings/SysUserModVirtualTableRoute.cs b/samples/Sample.SqlServer/Shardings/SysUserModVirtualTableRoute.cs index 3617d863..b9a18d09 100644 --- a/samples/Sample.SqlServer/Shardings/SysUserModVirtualTableRoute.cs +++ b/samples/Sample.SqlServer/Shardings/SysUserModVirtualTableRoute.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Linq.Expressions; using Sample.SqlServer.Domain.Entities; using ShardingCore.Core.EntityMetadatas; +using ShardingCore.Core.PhysicTables; using ShardingCore.Core.VirtualRoutes; using ShardingCore.Sharding.PaginationConfigurations; using ShardingCore.VirtualRoutes; @@ -25,6 +27,9 @@ namespace Sample.SqlServer.Shardings /// 开启提示路由 /// protected override bool EnableHintRoute => true; + /// + /// 开启断言路由 + /// protected override bool EnableAssertRoute => true; public SysUserModVirtualTableRoute() : base(2, 3) diff --git a/src/ShardingCore/Core/VirtualRoutes/TableRoutes/Abstractions/AbstractShardingFilterVirtualTableRoute.cs b/src/ShardingCore/Core/VirtualRoutes/TableRoutes/Abstractions/AbstractShardingFilterVirtualTableRoute.cs index 6352663c..3a0079c1 100644 --- a/src/ShardingCore/Core/VirtualRoutes/TableRoutes/Abstractions/AbstractShardingFilterVirtualTableRoute.cs +++ b/src/ShardingCore/Core/VirtualRoutes/TableRoutes/Abstractions/AbstractShardingFilterVirtualTableRoute.cs @@ -41,7 +41,7 @@ namespace ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions if (!isQuery) { //鍚庢嫤鎴櫒 - return AfterPhysicTableFilter(allPhysicTables,DoRouteWithPredicate(allPhysicTables,queryable)); + return DoRouteWithPredicate(allPhysicTables, queryable); } //寮哄埗璺敱涓嶇粡杩囨柇瑷 if (EnableHintRoute) diff --git a/src/ShardingCore/Sharding/MergeEngines/EnumeratorStreamMergeEngines/EnumeratorAsync/AppendOrderSequenceEnumeratorAsyncStreamMergeEngine.cs b/src/ShardingCore/Sharding/MergeEngines/EnumeratorStreamMergeEngines/EnumeratorAsync/AppendOrderSequenceEnumeratorAsyncStreamMergeEngine.cs index ce570843..68432cb1 100644 --- a/src/ShardingCore/Sharding/MergeEngines/EnumeratorStreamMergeEngines/EnumeratorAsync/AppendOrderSequenceEnumeratorAsyncStreamMergeEngine.cs +++ b/src/ShardingCore/Sharding/MergeEngines/EnumeratorStreamMergeEngines/EnumeratorAsync/AppendOrderSequenceEnumeratorAsyncStreamMergeEngine.cs @@ -64,18 +64,18 @@ namespace ShardingCore.Sharding.StreamMergeEngines.EnumeratorStreamMergeEngines. //if sharding data source var appendAsc = _dataSourceSequenceOrderConfig.AppendAsc; //if sharding table - var useThenBy = dataSourceOrderMain && _tableSequenceOrderConfig != null; + var useThenBy = _tableSequenceOrderConfig != null; if (appendAsc) { sortRouteResults = sortRouteResults.OrderBy(o => o.DataSourceName, _dataSourceSequenceOrderConfig.RouteComparer) - .ThenByIf(o => o.Tail, useThenBy && _tableSequenceOrderConfig.AppendAsc, _tableSequenceOrderConfig.RouteComparer) - .ThenByDescendingIf(o => o.Tail, useThenBy && !_tableSequenceOrderConfig.AppendAsc, _tableSequenceOrderConfig.RouteComparer); + .ThenByIf(o => o.Tail, useThenBy && _tableSequenceOrderConfig.AppendAsc, _tableSequenceOrderConfig?.RouteComparer) + .ThenByDescendingIf(o => o.Tail, useThenBy && !_tableSequenceOrderConfig.AppendAsc, _tableSequenceOrderConfig?.RouteComparer); } else { sortRouteResults = sortRouteResults.OrderByDescending(o => o.DataSourceName, - _dataSourceSequenceOrderConfig.RouteComparer).ThenByDescendingIf(o => o.Tail, useThenBy, _tableSequenceOrderConfig.RouteComparer); + _dataSourceSequenceOrderConfig.RouteComparer).ThenByDescendingIf(o => o.Tail, useThenBy, _tableSequenceOrderConfig?.RouteComparer); } reSetOrders.Add(new PropertyOrder(_dataSourceSequenceOrderConfig.PropertyName, _dataSourceSequenceOrderConfig.AppendAsc)); if (useThenBy) diff --git a/src/ShardingCore/VirtualRoutes/Abstractions/AbstractShardingAutoCreateOperatorVirtualTableRoute.cs b/src/ShardingCore/VirtualRoutes/Abstractions/AbstractShardingAutoCreateOperatorVirtualTableRoute.cs index 371cde14..95d383a8 100644 --- a/src/ShardingCore/VirtualRoutes/Abstractions/AbstractShardingAutoCreateOperatorVirtualTableRoute.cs +++ b/src/ShardingCore/VirtualRoutes/Abstractions/AbstractShardingAutoCreateOperatorVirtualTableRoute.cs @@ -26,6 +26,9 @@ namespace ShardingCore.VirtualRoutes.Abstractions _logger = ShardingContainer .GetService>>(); } + /// + /// 涓嶅彲浠ヨ缃竴鏍 + /// public virtual string JobName => $"{EntityMetadata?.ShardingDbContextType?.Name}:{EntityMetadata?.EntityType?.Name}";