Skip to content

Commit

Permalink
支持string.Compare和string.CompareTo方法对字符串的排序用于处理雪花id的字符串排序比较,并且发布x.4.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
xuejmnet committed Mar 7, 2022
1 parent 89b86c2 commit d00df96
Show file tree
Hide file tree
Showing 4 changed files with 242 additions and 221 deletions.
8 changes: 4 additions & 4 deletions nuget-publish.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
:start
::定义版本
set EFCORE2=2.4.2.02
set EFCORE3=3.4.2.02
set EFCORE5=5.4.2.02
set EFCORE6=6.4.2.02
set EFCORE2=2.4.2.03
set EFCORE3=3.4.2.03
set EFCORE5=5.4.2.03
set EFCORE6=6.4.2.03

::删除所有bin与obj下的文件
@echo off
Expand Down
56 changes: 56 additions & 0 deletions src/ShardingCore/Extensions/CommonExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,62 @@ public static bool IsNamedEquals(this MethodCallExpression express)
{
return nameof(object.Equals).Equals(express.Method.Name);
}
//public static bool IsNamedCompareOrdinal(this BinaryExpression express)
//{
// express.
// return nameof(string.CompareOrdinal).Equals(express.Method.Name) || nameof(string.CompareTo).Equals(express.Method.Name) || nameof(string.Compare).Equals(express.Method.Name);
//}
public static bool IsNamedComparison(this BinaryExpression express,out MethodCallExpression methodCallExpression)
{
if (express.Left is MethodCallExpression m1 && m1.IsNamedComparison())
{
methodCallExpression = m1;
return true;
}
if (express.Right is MethodCallExpression m2 && m2.IsNamedComparison())
{
methodCallExpression = m2;
return true;
}

methodCallExpression = null;
return false;
}
public static bool GetComparisonLeftAndRight(this MethodCallExpression methodCallExpression, out (Expression Left,Expression Right) comparisonValue)
{

if (methodCallExpression.IsNamedCompare())
{
if (methodCallExpression.Arguments.Count == 2)
{
comparisonValue = (methodCallExpression.Arguments[0], methodCallExpression.Arguments[1]);
return true;
}
}

if (methodCallExpression.IsNamedCompareTo())
{
if (methodCallExpression.Arguments.Count == 1 && methodCallExpression.Object != null)
{
comparisonValue = (methodCallExpression.Object, methodCallExpression.Arguments[0]);
return true;
}
}
comparisonValue = (null,null);
return false;
}
public static bool IsNamedComparison(this MethodCallExpression express)
{
return express.IsNamedCompare() || express.IsNamedCompareTo();
}
public static bool IsNamedCompare(this MethodCallExpression express)
{
return nameof(string.CompareTo).Equals(express.Method.Name) || nameof(string.Compare).Equals(express.Method.Name);
}
public static bool IsNamedCompareTo(this MethodCallExpression express)
{
return nameof(string.CompareTo).Equals(express.Method.Name) || nameof(string.Compare).Equals(express.Method.Name);
}

public static ISet<Type> ParseQueryableEntities(this IQueryable queryable, Type dbContextType)
{
Expand Down
Loading

0 comments on commit d00df96

Please sign in to comment.