From 0b84219d4663c15c72ffbf74f620ed03490e8df1 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 13 Dec 2022 16:39:06 +0800 Subject: [PATCH] Update exp to sql --- .../SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs | 4 ++-- .../ResolveItems/MethodCallExpressionResolve_Helper.cs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs index ef179b5cc..0b92dd732 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs @@ -692,8 +692,8 @@ namespace SqlSugar public string CompareTo(MethodCallExpressionModel model) { var parameterNameA=model.Args[0].MemberName; - var parameterNameB = model.Args[0].MemberName; - return $"(case when '{parameterNameA}'>'{parameterNameB}' then 1 when '{parameterNameA}'='{parameterNameB}' then 0 else -1 end)"; + var parameterNameB = model.Args[1].MemberName; + return $"(case when {parameterNameA}>{parameterNameB} then 1 when {parameterNameA}={parameterNameB} then 0 else -1 end)"; } } } diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs index 4175d1648..bc9b1daee 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs @@ -792,6 +792,10 @@ namespace SqlSugar { return true; } + if (expression.Method.Name == "CompareTo") + { + return true; + } if (expression.Method.Name == "Format" && expression.Method.DeclaringType == UtilConstants.StringType) { return true;