单元测试缓存,并且移除表达式编译缓存功能
This commit is contained in:
parent
318e51bbf0
commit
28c6aa1fbd
|
@ -113,7 +113,7 @@ namespace ShardingCore6x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Params(1)]
|
[Params(10)]
|
||||||
public int N;
|
public int N;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace ShardingCore6x.ShardingDbContexts
|
||||||
{
|
{
|
||||||
internal class OrderVirtualTableRoute:AbstractSimpleShardingModKeyStringVirtualTableRoute<Order>
|
internal class OrderVirtualTableRoute:AbstractSimpleShardingModKeyStringVirtualTableRoute<Order>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
////public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public OrderVirtualTableRoute() : base(2, 5)
|
public OrderVirtualTableRoute() : base(2, 5)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,7 @@ builder.Services.AddShardingDbContext<DefaultDbContext>()
|
||||||
.AddConfig(o =>
|
.AddConfig(o =>
|
||||||
{
|
{
|
||||||
o.ConfigId = "c1";
|
o.ConfigId = "c1";
|
||||||
o.AddDefaultDataSource("ds0", "server=127.0.0.1;port=3306;database=shardingTest;userid=root;password=root;");
|
o.AddDefaultDataSource("ds0", "server=127.0.0.1;port=3306;database=shardingTest;userid=root;password=L6yBtV6qNENrwBy7;");
|
||||||
o.UseShardingQuery((conn, b) =>
|
o.UseShardingQuery((conn, b) =>
|
||||||
{
|
{
|
||||||
b.UseMySql(conn, new MySqlServerVersion(new Version())).UseLoggerFactory(efLogger);
|
b.UseMySql(conn, new MySqlServerVersion(new Version())).UseLoggerFactory(efLogger);
|
||||||
|
|
|
@ -31,16 +31,16 @@ namespace ShardingCore.Core.ShardingConfigurations.Abstractions
|
||||||
/// 忽略建表时的错误
|
/// 忽略建表时的错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool? IgnoreCreateTableError { get; set; }
|
bool? IgnoreCreateTableError { get; set; }
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 是否启用分表路由编译缓存(默认只缓存单个操作的也就是<![CDATA[=,>,>=,<,<=]]>)
|
///// 是否启用分表路由编译缓存(默认只缓存单个操作的也就是<![CDATA[=,>,>=,<,<=]]>)
|
||||||
/// default cache single filter route expression, <![CDATA[=,>,>=,<,<=]]> with sharding property
|
///// default cache single filter route expression, <![CDATA[=,>,>=,<,<=]]> with sharding property
|
||||||
/// </summary>
|
///// </summary>
|
||||||
bool? EnableTableRouteCompileCache { get; set; }
|
//bool? EnableTableRouteCompileCache { get; set; }
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 是否启用分库路由编译缓存(默认只缓存单个操作的也就是<![CDATA[=,>,>=,<,<=]]>)
|
///// 是否启用分库路由编译缓存(默认只缓存单个操作的也就是<![CDATA[=,>,>=,<,<=]]>)
|
||||||
/// default cache single filter route expression, <![CDATA[=,>,>=,<,<=]]> with sharding property
|
///// default cache single filter route expression, <![CDATA[=,>,>=,<,<=]]> with sharding property
|
||||||
/// </summary>
|
///// </summary>
|
||||||
bool? EnableDataSourceRouteCompileCache { get; set; }
|
//bool? EnableDataSourceRouteCompileCache { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加分库路由
|
/// 添加分库路由
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -38,14 +38,14 @@ namespace ShardingCore.Core.ShardingConfigurations
|
||||||
/// 当查询遇到没有路由被命中时是否抛出错误
|
/// 当查询遇到没有路由被命中时是否抛出错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ThrowIfQueryRouteNotMatch { get; set; } = true;
|
public bool ThrowIfQueryRouteNotMatch { get; set; } = true;
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 全局启用分表路由表达式缓存,仅缓存单个表达式
|
///// 全局启用分表路由表达式缓存,仅缓存单个表达式
|
||||||
/// </summary>
|
///// </summary>
|
||||||
public bool? EnableTableRouteCompileCache { get; set; }
|
//public bool? EnableTableRouteCompileCache { get; set; }
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 全局启用分库路由表达式缓存,仅缓存单个表达式
|
///// 全局启用分库路由表达式缓存,仅缓存单个表达式
|
||||||
/// </summary>
|
///// </summary>
|
||||||
public bool? EnableDataSourceRouteCompileCache { get; set; }
|
//public bool? EnableDataSourceRouteCompileCache { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 忽略建表时的错误
|
/// 忽略建表时的错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace ShardingCore.Core.VirtualRoutes.DataSourceRoutes.Abstractions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TEntity"></typeparam>
|
/// <typeparam name="TEntity"></typeparam>
|
||||||
/// <typeparam name="TKey"></typeparam>
|
/// <typeparam name="TKey"></typeparam>
|
||||||
public abstract class AbstractShardingOperatorVirtualDataSourceRoute<TEntity, TKey> : AbstractShardingRouteParseCompileCacheVirtualDataSourceRoute<TEntity, TKey> where TEntity : class
|
public abstract class AbstractShardingOperatorVirtualDataSourceRoute<TEntity, TKey> : AbstractShardingFilterVirtualDataSourceRoute<TEntity, TKey> where TEntity : class
|
||||||
{
|
{
|
||||||
protected override List<string> DoRouteWithPredicate(List<string> allDataSourceNames, IQueryable queryable)
|
protected override List<string> DoRouteWithPredicate(List<string> allDataSourceNames, IQueryable queryable)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,94 +1,94 @@
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Concurrent;
|
//using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using System.Linq.Expressions;
|
//using System.Linq.Expressions;
|
||||||
using System.Text;
|
//using System.Text;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
using ShardingCore.Extensions;
|
//using ShardingCore.Extensions;
|
||||||
using ShardingCore.Sharding.Visitors;
|
//using ShardingCore.Sharding.Visitors;
|
||||||
|
|
||||||
namespace ShardingCore.Core.VirtualRoutes.DataSourceRoutes.Abstractions
|
//namespace ShardingCore.Core.VirtualRoutes.DataSourceRoutes.Abstractions
|
||||||
{
|
//{
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 分库路由表达式解析缓存
|
// /// 分库路由表达式解析缓存
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <typeparam name="TEntity"></typeparam>
|
// /// <typeparam name="TEntity"></typeparam>
|
||||||
/// <typeparam name="TKey"></typeparam>
|
// /// <typeparam name="TKey"></typeparam>
|
||||||
public abstract class AbstractShardingRouteParseCompileCacheVirtualDataSourceRoute<TEntity, TKey> : AbstractShardingFilterVirtualDataSourceRoute<TEntity, TKey> where TEntity : class
|
// public abstract class AbstractShardingRouteParseCompileCacheVirtualDataSourceRoute<TEntity, TKey> : AbstractShardingFilterVirtualDataSourceRoute<TEntity, TKey> where TEntity : class
|
||||||
{
|
// {
|
||||||
private static readonly ConcurrentDictionary<Expression<Func<string, bool>>, Func<string, bool>> _routeCompileCaches = new(new ExtensionExpressionComparer.RouteParseExpressionEqualityComparer());
|
// private static readonly ConcurrentDictionary<Expression<Func<string, bool>>, Func<string, bool>> _routeCompileCaches = new(new ExtensionExpressionComparer.RouteParseExpressionEqualityComparer());
|
||||||
static AbstractShardingRouteParseCompileCacheVirtualDataSourceRoute()
|
// static AbstractShardingRouteParseCompileCacheVirtualDataSourceRoute()
|
||||||
{
|
// {
|
||||||
Expression<Func<string, bool>> defaultWhere1 = x => true;
|
// Expression<Func<string, bool>> defaultWhere1 = x => true;
|
||||||
_routeCompileCaches.TryAdd(defaultWhere1, defaultWhere1.Compile());
|
// _routeCompileCaches.TryAdd(defaultWhere1, defaultWhere1.Compile());
|
||||||
Expression<Func<string, bool>> defaultWhere2 = x => true;
|
// Expression<Func<string, bool>> defaultWhere2 = x => true;
|
||||||
var expression = defaultWhere2.And(defaultWhere1);
|
// var expression = defaultWhere2.And(defaultWhere1);
|
||||||
_routeCompileCaches.TryAdd(expression, expression.Compile());
|
// _routeCompileCaches.TryAdd(expression, expression.Compile());
|
||||||
}
|
// }
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 是否启用路由解析编译缓存
|
// /// 是否启用路由解析编译缓存
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public virtual bool? EnableRouteParseCompileCache => null;
|
// public virtual bool? EnableRouteParseCompileCache => null;
|
||||||
|
|
||||||
public virtual bool EnableCompileCache()
|
// public virtual bool EnableCompileCache()
|
||||||
{
|
// {
|
||||||
if (EnableRouteParseCompileCache.HasValue)
|
// if (EnableRouteParseCompileCache.HasValue)
|
||||||
return EnableRouteParseCompileCache.Value;
|
// return EnableRouteParseCompileCache.Value;
|
||||||
return EntityConfigOptions.EnableDataSourceRouteCompileCache.GetValueOrDefault();
|
// return EntityConfigOptions.EnableDataSourceRouteCompileCache.GetValueOrDefault();
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 对表达式进行缓存编译默认永久缓存单个参数表达式,且不包含orElse只包含单个AndAlso或者没有AndAlso的,
|
// /// 对表达式进行缓存编译默认永久缓存单个参数表达式,且不包含orElse只包含单个AndAlso或者没有AndAlso的,
|
||||||
/// 比如:<![CDATA[o.id==x]]>或者<![CDATA[o.id>x]]>,不会缓存<![CDATA[o=>id>x && o.id<y ]]>等一共大于、等于、小于、大于等于、小于等于(不等于编译成<![CDATA[t=>true]]>)缓存会存在的数量个数上限为
|
// /// 比如:<![CDATA[o.id==x]]>或者<![CDATA[o.id>x]]>,不会缓存<![CDATA[o=>id>x && o.id<y ]]>等一共大于、等于、小于、大于等于、小于等于(不等于编译成<![CDATA[t=>true]]>)缓存会存在的数量个数上限为
|
||||||
/// 表后缀x*5+2,当前表如果有300个后缀那么就是1502个缓存结果额外两个为<![CDATA[o=>true]]>和<![CDATA[o=>true and true]]>
|
// /// 表后缀x*5+2,当前表如果有300个后缀那么就是1502个缓存结果额外两个为<![CDATA[o=>true]]>和<![CDATA[o=>true and true]]>
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="parseWhere"></param>
|
// /// <param name="parseWhere"></param>
|
||||||
/// <returns></returns>
|
// /// <returns></returns>
|
||||||
public virtual Func<string, bool> CachingCompile(Expression<Func<string, bool>> parseWhere)
|
// public virtual Func<string, bool> CachingCompile(Expression<Func<string, bool>> parseWhere)
|
||||||
{
|
// {
|
||||||
if (EnableCompileCache())
|
// if (EnableCompileCache())
|
||||||
{
|
// {
|
||||||
var doCachingCompile = DoCachingCompile(parseWhere);
|
// var doCachingCompile = DoCachingCompile(parseWhere);
|
||||||
if (doCachingCompile != null)
|
// if (doCachingCompile != null)
|
||||||
return doCachingCompile;
|
// return doCachingCompile;
|
||||||
doCachingCompile = CustomerCachingCompile(parseWhere);
|
// doCachingCompile = CustomerCachingCompile(parseWhere);
|
||||||
if (doCachingCompile != null)
|
// if (doCachingCompile != null)
|
||||||
return doCachingCompile;
|
// return doCachingCompile;
|
||||||
}
|
// }
|
||||||
return parseWhere.Compile();
|
// return parseWhere.Compile();
|
||||||
}
|
// }
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 系统默认永久单表达式缓存
|
// /// 系统默认永久单表达式缓存
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="parseWhere"></param>
|
// /// <param name="parseWhere"></param>
|
||||||
/// <returns>返回null会走<see cref="CustomerCachingCompile"/>这个方法如果还是null就会调用<see cref="Compile"/>方法</returns>
|
// /// <returns>返回null会走<see cref="CustomerCachingCompile"/>这个方法如果还是null就会调用<see cref="Compile"/>方法</returns>
|
||||||
protected virtual Func<string, bool> DoCachingCompile(Expression<Func<string, bool>> parseWhere)
|
// protected virtual Func<string, bool> DoCachingCompile(Expression<Func<string, bool>> parseWhere)
|
||||||
{
|
// {
|
||||||
var shouldCache = ShouldCache(parseWhere);
|
// var shouldCache = ShouldCache(parseWhere);
|
||||||
if (shouldCache)
|
// if (shouldCache)
|
||||||
return _routeCompileCaches.GetOrAdd(parseWhere, key => parseWhere.Compile());
|
// return _routeCompileCaches.GetOrAdd(parseWhere, key => parseWhere.Compile());
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 表达式是否应该被缓存默认没有or并且and只有一个或者没有
|
// /// 表达式是否应该被缓存默认没有or并且and只有一个或者没有
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="whereExpression"></param>
|
// /// <param name="whereExpression"></param>
|
||||||
/// <returns></returns>
|
// /// <returns></returns>
|
||||||
protected bool ShouldCache(Expression whereExpression)
|
// protected bool ShouldCache(Expression whereExpression)
|
||||||
{
|
// {
|
||||||
var routeParseCacheExpressionVisitor = new RouteParseCacheExpressionVisitor();
|
// var routeParseCacheExpressionVisitor = new RouteParseCacheExpressionVisitor();
|
||||||
routeParseCacheExpressionVisitor.Visit(whereExpression);
|
// routeParseCacheExpressionVisitor.Visit(whereExpression);
|
||||||
if (routeParseCacheExpressionVisitor.HasOrElse())
|
// if (routeParseCacheExpressionVisitor.HasOrElse())
|
||||||
return false;
|
// return false;
|
||||||
if (routeParseCacheExpressionVisitor.AndAlsoCount() > 1)
|
// if (routeParseCacheExpressionVisitor.AndAlsoCount() > 1)
|
||||||
return false;
|
// return false;
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
protected virtual Func<string, bool> CustomerCachingCompile(Expression<Func<string, bool>> parseWhere)
|
// protected virtual Func<string, bool> CustomerCachingCompile(Expression<Func<string, bool>> parseWhere)
|
||||||
{
|
// {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions
|
||||||
* @Date: Saturday, 19 December 2020 19:55:24
|
* @Date: Saturday, 19 December 2020 19:55:24
|
||||||
* @Email: 326308290@qq.com
|
* @Email: 326308290@qq.com
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractShardingOperatorVirtualTableRoute<TEntity, TKey> : AbstractShardingRouteParseCompileCacheVirtualTableRoute<TEntity, TKey> where TEntity : class
|
public abstract class AbstractShardingOperatorVirtualTableRoute<TEntity, TKey> : AbstractShardingFilterVirtualTableRoute<TEntity, TKey> where TEntity : class
|
||||||
{
|
{
|
||||||
protected override List<IPhysicTable> DoRouteWithPredicate(List<IPhysicTable> allPhysicTables, IQueryable queryable)
|
protected override List<IPhysicTable> DoRouteWithPredicate(List<IPhysicTable> allPhysicTables, IQueryable queryable)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,95 +1,95 @@
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Concurrent;
|
//using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using System.Linq.Expressions;
|
//using System.Linq.Expressions;
|
||||||
using System.Text;
|
//using System.Text;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
using ShardingCore.Core.EntityMetadatas;
|
//using ShardingCore.Core.EntityMetadatas;
|
||||||
using ShardingCore.Core.PhysicTables;
|
//using ShardingCore.Core.PhysicTables;
|
||||||
using ShardingCore.Extensions;
|
//using ShardingCore.Extensions;
|
||||||
using ShardingCore.Sharding.Visitors;
|
//using ShardingCore.Sharding.Visitors;
|
||||||
|
|
||||||
namespace ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions
|
//namespace ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions
|
||||||
{
|
//{
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 路由解析缓存
|
// /// 路由解析缓存
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <typeparam name="TEntity"></typeparam>
|
// /// <typeparam name="TEntity"></typeparam>
|
||||||
/// <typeparam name="TKey"></typeparam>
|
// /// <typeparam name="TKey"></typeparam>
|
||||||
public abstract class AbstractShardingRouteParseCompileCacheVirtualTableRoute<TEntity, TKey> : AbstractShardingFilterVirtualTableRoute<TEntity, TKey> where TEntity : class
|
// public abstract class AbstractShardingRouteParseCompileCacheVirtualTableRoute<TEntity, TKey> : AbstractShardingFilterVirtualTableRoute<TEntity, TKey> where TEntity : class
|
||||||
{
|
// {
|
||||||
private readonly ConcurrentDictionary<Expression<Func<string, bool>>, Func<string, bool>> _routeCompileCaches = new(new ExtensionExpressionComparer.RouteParseExpressionEqualityComparer());
|
// private readonly ConcurrentDictionary<Expression<Func<string, bool>>, Func<string, bool>> _routeCompileCaches = new(new ExtensionExpressionComparer.RouteParseExpressionEqualityComparer());
|
||||||
|
|
||||||
protected AbstractShardingRouteParseCompileCacheVirtualTableRoute()
|
// protected AbstractShardingRouteParseCompileCacheVirtualTableRoute()
|
||||||
{
|
// {
|
||||||
Expression<Func<string, bool>> defaultWhere1 = x => true;
|
// Expression<Func<string, bool>> defaultWhere1 = x => true;
|
||||||
_routeCompileCaches.TryAdd(defaultWhere1, defaultWhere1.Compile());
|
// _routeCompileCaches.TryAdd(defaultWhere1, defaultWhere1.Compile());
|
||||||
Expression<Func<string, bool>> defaultWhere2 = x => true;
|
// Expression<Func<string, bool>> defaultWhere2 = x => true;
|
||||||
var expression = defaultWhere2.And(defaultWhere1);
|
// var expression = defaultWhere2.And(defaultWhere1);
|
||||||
_routeCompileCaches.TryAdd(expression, expression.Compile());
|
// _routeCompileCaches.TryAdd(expression, expression.Compile());
|
||||||
}
|
// }
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 是否启用路由解析编译缓存
|
// /// 是否启用路由解析编译缓存
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public virtual bool? EnableRouteParseCompileCache => null;
|
// public virtual bool? EnableRouteParseCompileCache => null;
|
||||||
public virtual bool EnableCompileCache()
|
// public virtual bool EnableCompileCache()
|
||||||
{
|
// {
|
||||||
if (EnableRouteParseCompileCache.HasValue)
|
// if (EnableRouteParseCompileCache.HasValue)
|
||||||
return EnableRouteParseCompileCache.Value;
|
// return EnableRouteParseCompileCache.Value;
|
||||||
return EntityConfigOptions.EnableTableRouteCompileCache.GetValueOrDefault();
|
// return EntityConfigOptions.EnableTableRouteCompileCache.GetValueOrDefault();
|
||||||
}
|
// }
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 对表达式进行缓存编译默认永久缓存单个参数表达式,且不包含orElse只包含单个AndAlso或者没有AndAlso的,
|
// /// 对表达式进行缓存编译默认永久缓存单个参数表达式,且不包含orElse只包含单个AndAlso或者没有AndAlso的,
|
||||||
/// 比如:<![CDATA[o.id==x]]>或者<![CDATA[o.id>x]]>,不会缓存<![CDATA[o=>id>x && o.id<y ]]>等一共大于、等于、小于、大于等于、小于等于(不等于编译成<![CDATA[t=>true]]>)缓存会存在的数量个数上限为
|
// /// 比如:<![CDATA[o.id==x]]>或者<![CDATA[o.id>x]]>,不会缓存<![CDATA[o=>id>x && o.id<y ]]>等一共大于、等于、小于、大于等于、小于等于(不等于编译成<![CDATA[t=>true]]>)缓存会存在的数量个数上限为
|
||||||
/// 表后缀x*5+2,当前表如果有300个后缀那么就是1502个缓存结果额外两个为<![CDATA[o=>true]]>和<![CDATA[o=>true and true]]>
|
// /// 表后缀x*5+2,当前表如果有300个后缀那么就是1502个缓存结果额外两个为<![CDATA[o=>true]]>和<![CDATA[o=>true and true]]>
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="parseWhere"></param>
|
// /// <param name="parseWhere"></param>
|
||||||
/// <returns></returns>
|
// /// <returns></returns>
|
||||||
public virtual Func<string, bool> CachingCompile(Expression<Func<string, bool>> parseWhere)
|
// public virtual Func<string, bool> CachingCompile(Expression<Func<string, bool>> parseWhere)
|
||||||
{
|
// {
|
||||||
if (EnableCompileCache())
|
// if (EnableCompileCache())
|
||||||
{
|
// {
|
||||||
var doCachingCompile = DoCachingCompile(parseWhere);
|
// var doCachingCompile = DoCachingCompile(parseWhere);
|
||||||
if (doCachingCompile != null)
|
// if (doCachingCompile != null)
|
||||||
return doCachingCompile;
|
// return doCachingCompile;
|
||||||
doCachingCompile = CustomerCachingCompile(parseWhere);
|
// doCachingCompile = CustomerCachingCompile(parseWhere);
|
||||||
if (doCachingCompile != null)
|
// if (doCachingCompile != null)
|
||||||
return doCachingCompile;
|
// return doCachingCompile;
|
||||||
}
|
// }
|
||||||
return parseWhere.Compile();
|
// return parseWhere.Compile();
|
||||||
}
|
// }
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 系统默认永久单表达式缓存
|
// /// 系统默认永久单表达式缓存
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="parseWhere"></param>
|
// /// <param name="parseWhere"></param>
|
||||||
/// <returns>返回null会走<see cref="CustomerCachingCompile"/>这个方法如果还是null就会调用<see cref="LambdaExpression.Compile()"/>方法</returns>
|
// /// <returns>返回null会走<see cref="CustomerCachingCompile"/>这个方法如果还是null就会调用<see cref="LambdaExpression.Compile()"/>方法</returns>
|
||||||
protected virtual Func<string, bool> DoCachingCompile(Expression<Func<string, bool>> parseWhere)
|
// protected virtual Func<string, bool> DoCachingCompile(Expression<Func<string, bool>> parseWhere)
|
||||||
{
|
// {
|
||||||
var shouldCache = ShouldCache(parseWhere);
|
// var shouldCache = ShouldCache(parseWhere);
|
||||||
if(shouldCache)
|
// if(shouldCache)
|
||||||
return _routeCompileCaches.GetOrAdd(parseWhere, key => parseWhere.Compile());
|
// return _routeCompileCaches.GetOrAdd(parseWhere, key => parseWhere.Compile());
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 表达式是否应该被缓存默认没有or并且and只有一个或者没有
|
// /// 表达式是否应该被缓存默认没有or并且and只有一个或者没有
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="whereExpression"></param>
|
// /// <param name="whereExpression"></param>
|
||||||
/// <returns></returns>
|
// /// <returns></returns>
|
||||||
protected bool ShouldCache(Expression whereExpression)
|
// protected bool ShouldCache(Expression whereExpression)
|
||||||
{
|
// {
|
||||||
var routeParseCacheExpressionVisitor = new RouteParseCacheExpressionVisitor();
|
// var routeParseCacheExpressionVisitor = new RouteParseCacheExpressionVisitor();
|
||||||
routeParseCacheExpressionVisitor.Visit(whereExpression);
|
// routeParseCacheExpressionVisitor.Visit(whereExpression);
|
||||||
if (routeParseCacheExpressionVisitor.HasOrElse())
|
// if (routeParseCacheExpressionVisitor.HasOrElse())
|
||||||
return false;
|
// return false;
|
||||||
if (routeParseCacheExpressionVisitor.AndAlsoCount() > 1)
|
// if (routeParseCacheExpressionVisitor.AndAlsoCount() > 1)
|
||||||
return false;
|
// return false;
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
protected virtual Func<string, bool> CustomerCachingCompile(Expression<Func<string, bool>> parseWhere)
|
// protected virtual Func<string, bool> CustomerCachingCompile(Expression<Func<string, bool>> parseWhere)
|
||||||
{
|
// {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -17,8 +17,11 @@
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Remove="Core\VirtualRoutes\RouteConditions\**" />
|
||||||
<Compile Remove="Sharding\Abstractions\MergeParseContexts\**" />
|
<Compile Remove="Sharding\Abstractions\MergeParseContexts\**" />
|
||||||
|
<EmbeddedResource Remove="Core\VirtualRoutes\RouteConditions\**" />
|
||||||
<EmbeddedResource Remove="Sharding\Abstractions\MergeParseContexts\**" />
|
<EmbeddedResource Remove="Sharding\Abstractions\MergeParseContexts\**" />
|
||||||
|
<None Remove="Core\VirtualRoutes\RouteConditions\**" />
|
||||||
<None Remove="Sharding\Abstractions\MergeParseContexts\**" />
|
<None Remove="Sharding\Abstractions\MergeParseContexts\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -34,7 +37,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Core\VirtualRoutes\RouteConditions" />
|
|
||||||
<Folder Include="Sharding\Visitors\GroupBys" />
|
<Folder Include="Sharding\Visitors\GroupBys" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ShardingCore.Test.Shardings
|
||||||
{
|
{
|
||||||
public class LogDayLongVirtualRoute:AbstractSimpleShardingDayKeyLongVirtualTableRoute<LogDayLong>
|
public class LogDayLongVirtualRoute:AbstractSimpleShardingDayKeyLongVirtualTableRoute<LogDayLong>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
|
|
||||||
public override void Configure(EntityMetadataTableBuilder<LogDayLong> builder)
|
public override void Configure(EntityMetadataTableBuilder<LogDayLong> builder)
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace ShardingCore.Test.Shardings
|
||||||
{
|
{
|
||||||
public class LogDayVirtualTableRoute:AbstractSimpleShardingDayKeyDateTimeVirtualTableRoute<LogDay>
|
public class LogDayVirtualTableRoute:AbstractSimpleShardingDayKeyDateTimeVirtualTableRoute<LogDay>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
|
|
||||||
public override DateTime GetBeginTime()
|
public override DateTime GetBeginTime()
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ShardingCore.Test.Shardings
|
||||||
{
|
{
|
||||||
public class LogMonthLongvirtualRoute:AbstractSimpleShardingMonthKeyLongVirtualTableRoute<LogMonthLong>
|
public class LogMonthLongvirtualRoute:AbstractSimpleShardingMonthKeyLongVirtualTableRoute<LogMonthLong>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace ShardingCore.Test.Shardings
|
||||||
{
|
{
|
||||||
public class LogWeekDateTimeVirtualTableRoute:AbstractSimpleShardingWeekKeyDateTimeVirtualTableRoute<LogWeekDateTime>
|
public class LogWeekDateTimeVirtualTableRoute:AbstractSimpleShardingWeekKeyDateTimeVirtualTableRoute<LogWeekDateTime>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace ShardingCore.Test.Shardings
|
||||||
{
|
{
|
||||||
public class LogWeekTimeLongVirtualTableRoute : AbstractSimpleShardingWeekKeyLongVirtualTableRoute<LogWeekTimeLong>
|
public class LogWeekTimeLongVirtualTableRoute : AbstractSimpleShardingWeekKeyLongVirtualTableRoute<LogWeekTimeLong>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace ShardingCore.Test.Shardings
|
||||||
{
|
{
|
||||||
public class LogYearDateTimeVirtualRoute:AbstractSimpleShardingYearKeyDateTimeVirtualTableRoute<LogYearDateTime>
|
public class LogYearDateTimeVirtualRoute:AbstractSimpleShardingYearKeyDateTimeVirtualTableRoute<LogYearDateTime>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace ShardingCore.Test.Shardings
|
||||||
{
|
{
|
||||||
public class LogYearLongVirtualRoute:AbstractSimpleShardingYearKeyLongVirtualTableRoute<LogYearLong>
|
public class LogYearLongVirtualRoute:AbstractSimpleShardingYearKeyLongVirtualTableRoute<LogYearLong>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
|
|
||||||
public override void Configure(EntityMetadataTableBuilder<LogYearLong> builder)
|
public override void Configure(EntityMetadataTableBuilder<LogYearLong> builder)
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace ShardingCore.Test.Shardings
|
||||||
{
|
{
|
||||||
public class OrderAreaShardingVirtualDataSourceRoute:AbstractShardingOperatorVirtualDataSourceRoute<Order,string>
|
public class OrderAreaShardingVirtualDataSourceRoute:AbstractShardingOperatorVirtualDataSourceRoute<Order,string>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
protected override bool EnableHintRoute =>true;
|
protected override bool EnableHintRoute =>true;
|
||||||
|
|
||||||
private readonly List<string> _dataSources = new List<string>()
|
private readonly List<string> _dataSources = new List<string>()
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace ShardingCore.Test.Shardings
|
||||||
{
|
{
|
||||||
public class OrderCreateTimeVirtualTableRoute:AbstractSimpleShardingMonthKeyDateTimeVirtualTableRoute<Order>
|
public class OrderCreateTimeVirtualTableRoute:AbstractSimpleShardingMonthKeyDateTimeVirtualTableRoute<Order>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
public override DateTime GetBeginTime()
|
public override DateTime GetBeginTime()
|
||||||
{
|
{
|
||||||
return new DateTime(2021, 1, 1);
|
return new DateTime(2021, 1, 1);
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ShardingCore.Test.Shardings
|
||||||
public class SysUserModIntVirtualRoute:AbstractSimpleShardingModKeyIntVirtualTableRoute<SysUserModInt>
|
public class SysUserModIntVirtualRoute:AbstractSimpleShardingModKeyIntVirtualTableRoute<SysUserModInt>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public SysUserModIntVirtualRoute() : base(2, 3)
|
public SysUserModIntVirtualRoute() : base(2, 3)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace ShardingCore.Test.Shardings
|
||||||
public class SysUserModVirtualTableRoute : AbstractSimpleShardingModKeyStringVirtualTableRoute<SysUserMod>
|
public class SysUserModVirtualTableRoute : AbstractSimpleShardingModKeyStringVirtualTableRoute<SysUserMod>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public SysUserModVirtualTableRoute() : base(2,3)
|
public SysUserModVirtualTableRoute() : base(2,3)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace ShardingCore.Test.Shardings
|
||||||
*/
|
*/
|
||||||
public class SysUserSalaryVirtualTableRoute:AbstractShardingOperatorVirtualTableRoute<SysUserSalary,int>
|
public class SysUserSalaryVirtualTableRoute:AbstractShardingOperatorVirtualTableRoute<SysUserSalary,int>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override string ShardingKeyToTail(object shardingKey)
|
public override string ShardingKeyToTail(object shardingKey)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace ShardingCore.Test2x.Shardings
|
||||||
public class LogDayLongVirtualRoute:AbstractSimpleShardingDayKeyLongVirtualTableRoute<LogDayLong>
|
public class LogDayLongVirtualRoute:AbstractSimpleShardingDayKeyLongVirtualTableRoute<LogDayLong>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
////public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override void Configure(EntityMetadataTableBuilder<LogDayLong> builder)
|
public override void Configure(EntityMetadataTableBuilder<LogDayLong> builder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace ShardingCore.Test2x.Shardings
|
||||||
public class LogDayVirtualTableRoute:AbstractSimpleShardingDayKeyDateTimeVirtualTableRoute<LogDay>
|
public class LogDayVirtualTableRoute:AbstractSimpleShardingDayKeyDateTimeVirtualTableRoute<LogDay>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override DateTime GetBeginTime()
|
public override DateTime GetBeginTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace ShardingCore.Test2x.Shardings
|
||||||
public class LogMonthLongvirtualRoute:AbstractSimpleShardingMonthKeyLongVirtualTableRoute<LogMonthLong>
|
public class LogMonthLongvirtualRoute:AbstractSimpleShardingMonthKeyLongVirtualTableRoute<LogMonthLong>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace ShardingCore.Test2x.Shardings
|
||||||
public class LogWeekDateTimeVirtualTableRoute:AbstractSimpleShardingWeekKeyDateTimeVirtualTableRoute<LogWeekDateTime>
|
public class LogWeekDateTimeVirtualTableRoute:AbstractSimpleShardingWeekKeyDateTimeVirtualTableRoute<LogWeekDateTime>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace ShardingCore.Test2x.Shardings
|
||||||
public class LogWeekTimeLongVirtualTableRoute : AbstractSimpleShardingWeekKeyLongVirtualTableRoute<LogWeekTimeLong>
|
public class LogWeekTimeLongVirtualTableRoute : AbstractSimpleShardingWeekKeyLongVirtualTableRoute<LogWeekTimeLong>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace ShardingCore.Test2x.Shardings
|
||||||
public class LogYearDateTimeVirtualRoute:AbstractSimpleShardingYearKeyDateTimeVirtualTableRoute<LogYearDateTime>
|
public class LogYearDateTimeVirtualRoute:AbstractSimpleShardingYearKeyDateTimeVirtualTableRoute<LogYearDateTime>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace ShardingCore.Test2x.Shardings
|
||||||
public class LogYearLongVirtualRoute:AbstractSimpleShardingYearKeyLongVirtualTableRoute<LogYearLong>
|
public class LogYearLongVirtualRoute:AbstractSimpleShardingYearKeyLongVirtualTableRoute<LogYearLong>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override void Configure(EntityMetadataTableBuilder<LogYearLong> builder)
|
public override void Configure(EntityMetadataTableBuilder<LogYearLong> builder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ShardingCore.Test2x.Shardings
|
||||||
public class OrderAreaShardingVirtualDataSourceRoute:AbstractShardingOperatorVirtualDataSourceRoute<Order,string>
|
public class OrderAreaShardingVirtualDataSourceRoute:AbstractShardingOperatorVirtualDataSourceRoute<Order,string>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute =>true;
|
protected override bool EnableHintRoute =>true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
private readonly List<string> _dataSources = new List<string>()
|
private readonly List<string> _dataSources = new List<string>()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace ShardingCore.Test2x.Shardings
|
||||||
{
|
{
|
||||||
public class OrderCreateTimeVirtualTableRoute:AbstractSimpleShardingMonthKeyDateTimeVirtualTableRoute<Order>
|
public class OrderCreateTimeVirtualTableRoute:AbstractSimpleShardingMonthKeyDateTimeVirtualTableRoute<Order>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
public override DateTime GetBeginTime()
|
public override DateTime GetBeginTime()
|
||||||
{
|
{
|
||||||
return new DateTime(2021, 1, 1);
|
return new DateTime(2021, 1, 1);
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace ShardingCore.Test2x.Shardings
|
||||||
public class SysUserModIntVirtualRoute:AbstractSimpleShardingModKeyIntVirtualTableRoute<SysUserModInt>
|
public class SysUserModIntVirtualRoute:AbstractSimpleShardingModKeyIntVirtualTableRoute<SysUserModInt>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public SysUserModIntVirtualRoute() : base(2, 3)
|
public SysUserModIntVirtualRoute() : base(2, 3)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace ShardingCore.Test2x.Shardings
|
||||||
public class SysUserModVirtualTableRoute : AbstractSimpleShardingModKeyStringVirtualTableRoute<SysUserMod>
|
public class SysUserModVirtualTableRoute : AbstractSimpleShardingModKeyStringVirtualTableRoute<SysUserMod>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public SysUserModVirtualTableRoute() : base(2,3)
|
public SysUserModVirtualTableRoute() : base(2,3)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace ShardingCore.Test2x.Shardings
|
||||||
*/
|
*/
|
||||||
public class SysUserSalaryVirtualTableRoute:AbstractShardingOperatorVirtualTableRoute<SysUserSalary,int>
|
public class SysUserSalaryVirtualTableRoute:AbstractShardingOperatorVirtualTableRoute<SysUserSalary,int>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
public override string ShardingKeyToTail(object shardingKey)
|
public override string ShardingKeyToTail(object shardingKey)
|
||||||
{
|
{
|
||||||
var time = Convert.ToInt32(shardingKey);
|
var time = Convert.ToInt32(shardingKey);
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace ShardingCore.Test3x.Shardings
|
||||||
public class LogDayLongVirtualRoute:AbstractSimpleShardingDayKeyLongVirtualTableRoute<LogDayLong>
|
public class LogDayLongVirtualRoute:AbstractSimpleShardingDayKeyLongVirtualTableRoute<LogDayLong>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override void Configure(EntityMetadataTableBuilder<LogDayLong> builder)
|
public override void Configure(EntityMetadataTableBuilder<LogDayLong> builder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace ShardingCore.Test3x.Shardings
|
||||||
public class LogDayVirtualTableRoute:AbstractSimpleShardingDayKeyDateTimeVirtualTableRoute<LogDay>
|
public class LogDayVirtualTableRoute:AbstractSimpleShardingDayKeyDateTimeVirtualTableRoute<LogDay>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override DateTime GetBeginTime()
|
public override DateTime GetBeginTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ShardingCore.Test3x.Shardings
|
||||||
public class LogMonthLongvirtualRoute:AbstractSimpleShardingMonthKeyLongVirtualTableRoute<LogMonthLong>
|
public class LogMonthLongvirtualRoute:AbstractSimpleShardingMonthKeyLongVirtualTableRoute<LogMonthLong>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace ShardingCore.Test3x.Shardings
|
||||||
public class LogWeekDateTimeVirtualTableRoute:AbstractSimpleShardingWeekKeyDateTimeVirtualTableRoute<LogWeekDateTime>
|
public class LogWeekDateTimeVirtualTableRoute:AbstractSimpleShardingWeekKeyDateTimeVirtualTableRoute<LogWeekDateTime>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ShardingCore.Test3x.Shardings
|
||||||
public class LogWeekTimeLongVirtualTableRoute : AbstractSimpleShardingWeekKeyLongVirtualTableRoute<LogWeekTimeLong>
|
public class LogWeekTimeLongVirtualTableRoute : AbstractSimpleShardingWeekKeyLongVirtualTableRoute<LogWeekTimeLong>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ShardingCore.Test3x.Shardings
|
||||||
public class LogYearDateTimeVirtualRoute:AbstractSimpleShardingYearKeyDateTimeVirtualTableRoute<LogYearDateTime>
|
public class LogYearDateTimeVirtualRoute:AbstractSimpleShardingYearKeyDateTimeVirtualTableRoute<LogYearDateTime>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace ShardingCore.Test3x.Shardings
|
||||||
public class LogYearLongVirtualRoute:AbstractSimpleShardingYearKeyLongVirtualTableRoute<LogYearLong>
|
public class LogYearLongVirtualRoute:AbstractSimpleShardingYearKeyLongVirtualTableRoute<LogYearLong>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override void Configure(EntityMetadataTableBuilder<LogYearLong> builder)
|
public override void Configure(EntityMetadataTableBuilder<LogYearLong> builder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ShardingCore.Test3x.Shardings
|
||||||
public class OrderAreaShardingVirtualDataSourceRoute:AbstractShardingOperatorVirtualDataSourceRoute<Order,string>
|
public class OrderAreaShardingVirtualDataSourceRoute:AbstractShardingOperatorVirtualDataSourceRoute<Order,string>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute =>true;
|
protected override bool EnableHintRoute =>true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
private readonly List<string> _dataSources = new List<string>()
|
private readonly List<string> _dataSources = new List<string>()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace ShardingCore.Test3x.Shardings
|
||||||
{
|
{
|
||||||
public class OrderCreateTimeVirtualTableRoute:AbstractSimpleShardingMonthKeyDateTimeVirtualTableRoute<Order>
|
public class OrderCreateTimeVirtualTableRoute:AbstractSimpleShardingMonthKeyDateTimeVirtualTableRoute<Order>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
public override DateTime GetBeginTime()
|
public override DateTime GetBeginTime()
|
||||||
{
|
{
|
||||||
return new DateTime(2021, 1, 1);
|
return new DateTime(2021, 1, 1);
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace ShardingCore.Test3x.Shardings
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
|
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
public SysUserModIntVirtualRoute() : base(2, 3)
|
public SysUserModIntVirtualRoute() : base(2, 3)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace ShardingCore.Test3x.Shardings
|
||||||
public class SysUserModVirtualTableRoute : AbstractSimpleShardingModKeyStringVirtualTableRoute<SysUserMod>
|
public class SysUserModVirtualTableRoute : AbstractSimpleShardingModKeyStringVirtualTableRoute<SysUserMod>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public SysUserModVirtualTableRoute() : base(2,3)
|
public SysUserModVirtualTableRoute() : base(2,3)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace ShardingCore.Test3x.Shardings
|
||||||
public class SysUserSalaryVirtualTableRoute:AbstractShardingOperatorVirtualTableRoute<SysUserSalary,int>
|
public class SysUserSalaryVirtualTableRoute:AbstractShardingOperatorVirtualTableRoute<SysUserSalary,int>
|
||||||
{
|
{
|
||||||
|
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
public override string ShardingKeyToTail(object shardingKey)
|
public override string ShardingKeyToTail(object shardingKey)
|
||||||
{
|
{
|
||||||
var time = Convert.ToInt32(shardingKey);
|
var time = Convert.ToInt32(shardingKey);
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace ShardingCore.Test5x.Shardings
|
||||||
public class LogDayLongVirtualRoute:AbstractSimpleShardingDayKeyLongVirtualTableRoute<LogDayLong>
|
public class LogDayLongVirtualRoute:AbstractSimpleShardingDayKeyLongVirtualTableRoute<LogDayLong>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override void Configure(EntityMetadataTableBuilder<LogDayLong> builder)
|
public override void Configure(EntityMetadataTableBuilder<LogDayLong> builder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace ShardingCore.Test5x.Shardings
|
||||||
public class LogDayVirtualTableRoute:AbstractSimpleShardingDayKeyDateTimeVirtualTableRoute<LogDay>
|
public class LogDayVirtualTableRoute:AbstractSimpleShardingDayKeyDateTimeVirtualTableRoute<LogDay>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override DateTime GetBeginTime()
|
public override DateTime GetBeginTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace ShardingCore.Test5x.Shardings
|
||||||
public class LogMonthLongvirtualRoute:AbstractSimpleShardingMonthKeyLongVirtualTableRoute<LogMonthLong>
|
public class LogMonthLongvirtualRoute:AbstractSimpleShardingMonthKeyLongVirtualTableRoute<LogMonthLong>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace ShardingCore.Test5x.Shardings
|
||||||
public class LogWeekDateTimeVirtualTableRoute:AbstractSimpleShardingWeekKeyDateTimeVirtualTableRoute<LogWeekDateTime>
|
public class LogWeekDateTimeVirtualTableRoute:AbstractSimpleShardingWeekKeyDateTimeVirtualTableRoute<LogWeekDateTime>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ShardingCore.Test5x.Shardings
|
||||||
public class LogWeekTimeLongVirtualTableRoute : AbstractSimpleShardingWeekKeyLongVirtualTableRoute<LogWeekTimeLong>
|
public class LogWeekTimeLongVirtualTableRoute : AbstractSimpleShardingWeekKeyLongVirtualTableRoute<LogWeekTimeLong>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ShardingCore.Test5x.Shardings
|
||||||
public class LogYearDateTimeVirtualRoute:AbstractSimpleShardingYearKeyDateTimeVirtualTableRoute<LogYearDateTime>
|
public class LogYearDateTimeVirtualRoute:AbstractSimpleShardingYearKeyDateTimeVirtualTableRoute<LogYearDateTime>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override bool AutoCreateTableByTime()
|
public override bool AutoCreateTableByTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace ShardingCore.Test5x.Shardings
|
||||||
public class LogYearLongVirtualRoute:AbstractSimpleShardingYearKeyLongVirtualTableRoute<LogYearLong>
|
public class LogYearLongVirtualRoute:AbstractSimpleShardingYearKeyLongVirtualTableRoute<LogYearLong>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public override void Configure(EntityMetadataTableBuilder<LogYearLong> builder)
|
public override void Configure(EntityMetadataTableBuilder<LogYearLong> builder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ShardingCore.Test5x.Shardings
|
||||||
public class OrderAreaShardingVirtualDataSourceRoute:AbstractShardingOperatorVirtualDataSourceRoute<Order,string>
|
public class OrderAreaShardingVirtualDataSourceRoute:AbstractShardingOperatorVirtualDataSourceRoute<Order,string>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute =>true;
|
protected override bool EnableHintRoute =>true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
private readonly List<string> _dataSources = new List<string>()
|
private readonly List<string> _dataSources = new List<string>()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace ShardingCore.Test5x.Shardings
|
||||||
{
|
{
|
||||||
public class OrderCreateTimeVirtualTableRoute:AbstractSimpleShardingMonthKeyDateTimeVirtualTableRoute<Order>
|
public class OrderCreateTimeVirtualTableRoute:AbstractSimpleShardingMonthKeyDateTimeVirtualTableRoute<Order>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
public override DateTime GetBeginTime()
|
public override DateTime GetBeginTime()
|
||||||
{
|
{
|
||||||
return new DateTime(2021, 1, 1);
|
return new DateTime(2021, 1, 1);
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ShardingCore.Test5x.Shardings
|
||||||
public class SysUserModIntVirtualRoute:AbstractSimpleShardingModKeyIntVirtualTableRoute<SysUserModInt>
|
public class SysUserModIntVirtualRoute:AbstractSimpleShardingModKeyIntVirtualTableRoute<SysUserModInt>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public SysUserModIntVirtualRoute() : base(2, 3)
|
public SysUserModIntVirtualRoute() : base(2, 3)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace ShardingCore.Test5x.Shardings
|
||||||
public class SysUserModVirtualTableRoute : AbstractSimpleShardingModKeyStringVirtualTableRoute<SysUserMod>
|
public class SysUserModVirtualTableRoute : AbstractSimpleShardingModKeyStringVirtualTableRoute<SysUserMod>
|
||||||
{
|
{
|
||||||
protected override bool EnableHintRoute => true;
|
protected override bool EnableHintRoute => true;
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
|
|
||||||
public SysUserModVirtualTableRoute() : base(2,3)
|
public SysUserModVirtualTableRoute() : base(2,3)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace ShardingCore.Test5x.Shardings
|
||||||
*/
|
*/
|
||||||
public class SysUserSalaryVirtualTableRoute:AbstractShardingOperatorVirtualTableRoute<SysUserSalary,int>
|
public class SysUserSalaryVirtualTableRoute:AbstractShardingOperatorVirtualTableRoute<SysUserSalary,int>
|
||||||
{
|
{
|
||||||
public override bool? EnableRouteParseCompileCache => true;
|
//public override bool? EnableRouteParseCompileCache => true;
|
||||||
public override string ShardingKeyToTail(object shardingKey)
|
public override string ShardingKeyToTail(object shardingKey)
|
||||||
{
|
{
|
||||||
var time = Convert.ToInt32(shardingKey);
|
var time = Convert.ToInt32(shardingKey);
|
||||||
|
|
Loading…
Reference in New Issue