Browse Source

Update exp to sql

pull/29/head
sunkaixuan 2 years ago
parent
commit
0b84219d46
  1. 4
      Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs
  2. 4
      Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs

4
Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs

@ -692,8 +692,8 @@ namespace SqlSugar
public string CompareTo(MethodCallExpressionModel model) public string CompareTo(MethodCallExpressionModel model)
{ {
var parameterNameA=model.Args[0].MemberName; var parameterNameA=model.Args[0].MemberName;
var parameterNameB = model.Args[0].MemberName; var parameterNameB = model.Args[1].MemberName;
return $"(case when '{parameterNameA}'>'{parameterNameB}' then 1 when '{parameterNameA}'='{parameterNameB}' then 0 else -1 end)"; return $"(case when {parameterNameA}>{parameterNameB} then 1 when {parameterNameA}={parameterNameB} then 0 else -1 end)";
} }
} }
} }

4
Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs

@ -792,6 +792,10 @@ namespace SqlSugar
{ {
return true; return true;
} }
if (expression.Method.Name == "CompareTo")
{
return true;
}
if (expression.Method.Name == "Format" && expression.Method.DeclaringType == UtilConstants.StringType) if (expression.Method.Name == "Format" && expression.Method.DeclaringType == UtilConstants.StringType)
{ {
return true; return true;

Loading…
Cancel
Save