mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-31 15:56:25 +08:00
Exp to sql :CompareTo
This commit is contained in:
parent
70a40ee578
commit
403add95d3
@ -689,5 +689,11 @@ namespace SqlSugar
|
||||
{
|
||||
throw new NotImplementedException("Current database no support");
|
||||
}
|
||||
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)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,5 +102,6 @@ namespace SqlSugar
|
||||
string AggregateSumNoNull(MethodCallExpressionModel model);
|
||||
string JsonListObjectAny(MethodCallExpressionModel model);
|
||||
string JsonArrayAny(MethodCallExpressionModel model);
|
||||
string CompareTo(MethodCallExpressionModel model);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,10 @@ namespace SqlSugar
|
||||
{
|
||||
public partial class SqlFunc
|
||||
{
|
||||
public static int CompareTo(string strA, string strB)
|
||||
{
|
||||
throw new NotSupportedException("Can only be used in expressions");
|
||||
}
|
||||
public static int RowNumber(object orderByField, object partitionBy)
|
||||
{
|
||||
throw new NotSupportedException("Can only be used in expressions");
|
||||
|
@ -756,6 +756,8 @@ namespace SqlSugar
|
||||
return this.Context.DbMehtods.JsonListObjectAny(model);
|
||||
case "JsonArrayAny":
|
||||
return this.Context.DbMehtods.JsonArrayAny(model);
|
||||
case "CompareTo":
|
||||
return this.Context.DbMehtods.CompareTo(model);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user