diff --git a/src/ShardingCore/Core/VirtualRoutes/ShardingOperatorEnum.cs b/src/ShardingCore/Core/VirtualRoutes/ShardingOperatorEnum.cs
index f2f126d1..cc3a399f 100644
--- a/src/ShardingCore/Core/VirtualRoutes/ShardingOperatorEnum.cs
+++ b/src/ShardingCore/Core/VirtualRoutes/ShardingOperatorEnum.cs
@@ -24,12 +24,12 @@ namespace ShardingCore.Core.VirtualRoutes
Equal,
[Description("!=")]
NotEqual,
- // [Description("%w%")]
- // AllLike,
- // [Description("%w")]
- // StartLike,
- // [Description("w%")]
- // EndLike
+ [Description("%w%")]
+ AllLike,
+ [Description("%w")]
+ StartLike,
+ [Description("w%")]
+ EndLike
// [Description("Contains")]
// BeContains
}
diff --git a/src/ShardingCore/Extensions/CommonExtension.cs b/src/ShardingCore/Extensions/CommonExtension.cs
index 5674e246..54c9d567 100644
--- a/src/ShardingCore/Extensions/CommonExtension.cs
+++ b/src/ShardingCore/Extensions/CommonExtension.cs
@@ -80,11 +80,26 @@ namespace ShardingCore.Extensions
/// 是否是集合contains方法
///
///
- ///
///
- public static bool IsEnumerableContains(this MethodCallExpression express, string methodName)
+ public static bool IsEnumerableContains(this MethodCallExpression express)
{
- return express.Method.DeclaringType.Namespace.IsIn("System.Linq", "System.Collections.Generic") && methodName == nameof(IList.Contains);
+ var methodName = express.Method.Name;
+ return methodName == nameof(IList.Contains)&& (express.Method.DeclaringType?.Namespace.IsInEnumerable()??false);
+ }
+ public static bool IsStringContains(this MethodCallExpression express)
+ {
+ var methodName = express.Method.Name;
+ return methodName == nameof(string.Contains)&& (express.Method.DeclaringType==typeof(string));
+ }
+ public static bool IsStringStartWith(this MethodCallExpression express)
+ {
+ var methodName = express.Method.Name;
+ return methodName == nameof(string.StartsWith)&& (express.Method.DeclaringType==typeof(string));
+ }
+ public static bool IsStringEndWith(this MethodCallExpression express)
+ {
+ var methodName = express.Method.Name;
+ return methodName == nameof(string.EndsWith)&& (express.Method.DeclaringType==typeof(string));
}
///
/// 是否是equal方法
diff --git a/src/ShardingCore/Extensions/LinqExtension.cs b/src/ShardingCore/Extensions/LinqExtension.cs
index 8522f07b..0e6f06b3 100644
--- a/src/ShardingCore/Extensions/LinqExtension.cs
+++ b/src/ShardingCore/Extensions/LinqExtension.cs
@@ -47,9 +47,14 @@ namespace ShardingCore.Extensions
{
return !source.IsEmpty();
}
- public static bool IsIn(this T thisValue, params T[] values)
+
+ private static readonly HashSet _enumerableContainsNamespace = new HashSet()
{
- return values.Contains(thisValue);
+ "System.Linq", "System.Collections.Generic"
+ };
+ public static bool IsInEnumerable(this string thisValue)
+ {
+ return _enumerableContainsNamespace.Contains(thisValue);
}
///
/// 按size分区,每个区size个数目
diff --git a/src/ShardingCore/Sharding/Visitors/QueryableRouteDiscoverVisitor.cs b/src/ShardingCore/Sharding/Visitors/QueryableRouteDiscoverVisitor.cs
index 2e3a3e5c..67d2867a 100644
--- a/src/ShardingCore/Sharding/Visitors/QueryableRouteDiscoverVisitor.cs
+++ b/src/ShardingCore/Sharding/Visitors/QueryableRouteDiscoverVisitor.cs
@@ -25,19 +25,45 @@ namespace ShardingCore.Core.Internal.Visitors
*/
public class QueryableRouteShardingTableDiscoverVisitor : ShardingExpressionVisitor
{
+ private static readonly Func _shardingOperatorFunc =
+ (conditionOnRight, nodeType) =>
+ {
+ var op = nodeType switch
+ {
+ ExpressionType.GreaterThan => conditionOnRight
+ ? ShardingOperatorEnum.GreaterThan
+ : ShardingOperatorEnum.LessThan,
+ ExpressionType.GreaterThanOrEqual => conditionOnRight
+ ? ShardingOperatorEnum.GreaterThanOrEqual
+ : ShardingOperatorEnum.LessThanOrEqual,
+ ExpressionType.LessThan => conditionOnRight
+ ? ShardingOperatorEnum.LessThan
+ : ShardingOperatorEnum.GreaterThan,
+ ExpressionType.LessThanOrEqual => conditionOnRight
+ ? ShardingOperatorEnum.LessThanOrEqual
+ : ShardingOperatorEnum.GreaterThanOrEqual,
+ ExpressionType.Equal => ShardingOperatorEnum.Equal,
+ ExpressionType.NotEqual => ShardingOperatorEnum.NotEqual,
+ _ => ShardingOperatorEnum.UnKnown
+ };
+ return op;
+ };
private readonly EntityMetadata _entityMetadata;
private readonly Func