优化整理代码
This commit is contained in:
parent
6e2bf99186
commit
4e11529c33
|
@ -11,6 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Sample.SqlServer.DbContexts;
|
using Sample.SqlServer.DbContexts;
|
||||||
using Sample.SqlServer.Domain.Entities;
|
using Sample.SqlServer.Domain.Entities;
|
||||||
|
using ShardingCore.Core.PhysicTables;
|
||||||
using ShardingCore.Core.QueryRouteManagers.Abstractions;
|
using ShardingCore.Core.QueryRouteManagers.Abstractions;
|
||||||
using ShardingCore.DbContexts.VirtualDbContexts;
|
using ShardingCore.DbContexts.VirtualDbContexts;
|
||||||
using ShardingCore.Extensions;
|
using ShardingCore.Extensions;
|
||||||
|
@ -89,7 +90,9 @@ namespace Sample.SqlServer.Controllers
|
||||||
|
|
||||||
using (_shardingRouteManager.CreateScope())
|
using (_shardingRouteManager.CreateScope())
|
||||||
{
|
{
|
||||||
_shardingRouteManager.Current.TryCreateOrAddMustTail<SysUserMod>("00");
|
_shardingRouteManager.Current.TryCreateOrAddMustTail<SysUserMod>("00","01");
|
||||||
|
//_shardingRouteManager.Current.TryCreateOrAddHintTail<SysUserMod>("00", "01");
|
||||||
|
//_shardingRouteManager.Current.TryCreateOrAddAssertTail<SysUserMod>(new TestRouteAssert());
|
||||||
|
|
||||||
var mod00s = await _defaultTableDbContext.Set<SysUserMod>().Skip(10).Take(11).ToListAsync();
|
var mod00s = await _defaultTableDbContext.Set<SysUserMod>().Skip(10).Take(11).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using Sample.SqlServer.Domain.Entities;
|
using Sample.SqlServer.Domain.Entities;
|
||||||
using ShardingCore.Core.EntityMetadatas;
|
using ShardingCore.Core.EntityMetadatas;
|
||||||
|
using ShardingCore.Core.PhysicTables;
|
||||||
using ShardingCore.Core.VirtualRoutes;
|
using ShardingCore.Core.VirtualRoutes;
|
||||||
using ShardingCore.Sharding.PaginationConfigurations;
|
using ShardingCore.Sharding.PaginationConfigurations;
|
||||||
using ShardingCore.VirtualRoutes;
|
using ShardingCore.VirtualRoutes;
|
||||||
|
@ -25,6 +27,9 @@ namespace Sample.SqlServer.Shardings
|
||||||
/// ¿ªÆôÌáʾ·ÓÉ
|
/// ¿ªÆôÌáʾ·ÓÉ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
|
/// <summary>
|
||||||
|
/// ¿ªÆô¶ÏÑÔ·ÓÉ
|
||||||
|
/// </summary>
|
||||||
protected override bool EnableAssertRoute => true;
|
protected override bool EnableAssertRoute => true;
|
||||||
|
|
||||||
public SysUserModVirtualTableRoute() : base(2, 3)
|
public SysUserModVirtualTableRoute() : base(2, 3)
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions
|
||||||
if (!isQuery)
|
if (!isQuery)
|
||||||
{
|
{
|
||||||
//后拦截器
|
//后拦截器
|
||||||
return AfterPhysicTableFilter(allPhysicTables,DoRouteWithPredicate(allPhysicTables,queryable));
|
return DoRouteWithPredicate(allPhysicTables, queryable);
|
||||||
}
|
}
|
||||||
//强制路由不经过断言
|
//强制路由不经过断言
|
||||||
if (EnableHintRoute)
|
if (EnableHintRoute)
|
||||||
|
|
|
@ -64,18 +64,18 @@ namespace ShardingCore.Sharding.StreamMergeEngines.EnumeratorStreamMergeEngines.
|
||||||
//if sharding data source
|
//if sharding data source
|
||||||
var appendAsc = _dataSourceSequenceOrderConfig.AppendAsc;
|
var appendAsc = _dataSourceSequenceOrderConfig.AppendAsc;
|
||||||
//if sharding table
|
//if sharding table
|
||||||
var useThenBy = dataSourceOrderMain && _tableSequenceOrderConfig != null;
|
var useThenBy = _tableSequenceOrderConfig != null;
|
||||||
if (appendAsc)
|
if (appendAsc)
|
||||||
{
|
{
|
||||||
sortRouteResults = sortRouteResults.OrderBy(o => o.DataSourceName,
|
sortRouteResults = sortRouteResults.OrderBy(o => o.DataSourceName,
|
||||||
_dataSourceSequenceOrderConfig.RouteComparer)
|
_dataSourceSequenceOrderConfig.RouteComparer)
|
||||||
.ThenByIf(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);
|
.ThenByDescendingIf(o => o.Tail, useThenBy && !_tableSequenceOrderConfig.AppendAsc, _tableSequenceOrderConfig?.RouteComparer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sortRouteResults = sortRouteResults.OrderByDescending(o => o.DataSourceName,
|
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));
|
reSetOrders.Add(new PropertyOrder(_dataSourceSequenceOrderConfig.PropertyName, _dataSourceSequenceOrderConfig.AppendAsc));
|
||||||
if (useThenBy)
|
if (useThenBy)
|
||||||
|
|
|
@ -26,6 +26,9 @@ namespace ShardingCore.VirtualRoutes.Abstractions
|
||||||
_logger = ShardingContainer
|
_logger = ShardingContainer
|
||||||
.GetService<ILogger<AbstractShardingAutoCreateOperatorVirtualTableRoute<TEntity, TKey>>>();
|
.GetService<ILogger<AbstractShardingAutoCreateOperatorVirtualTableRoute<TEntity, TKey>>>();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 不可以设置一样
|
||||||
|
/// </summary>
|
||||||
public virtual string JobName =>
|
public virtual string JobName =>
|
||||||
$"{EntityMetadata?.ShardingDbContextType?.Name}:{EntityMetadata?.EntityType?.Name}";
|
$"{EntityMetadata?.ShardingDbContextType?.Name}:{EntityMetadata?.EntityType?.Name}";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue