Browse Source

Synchronization code

pull/40/head
sunkaixuan 1 year ago
parent
commit
2c5d353b4f
  1. 4
      Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs
  2. 24
      Src/Asp.NetCore2/SqlSugar/Realization/MySql/SqlBuilder/MySqlExpressionContext.cs
  3. 4
      Src/Asp.NetCore2/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerExpressionContext.cs

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

@ -1016,14 +1016,14 @@ namespace SqlSugar
{
var parameterNameA = mode.Args[0].MemberName;
var parameterNameB= mode.Args[1].MemberName;
return $" TRIM(BOTH "+ parameterNameB + " FROM "+ parameterNameA + ") ";
return @$" CASE WHEN RIGHT({parameterNameA}, 1) = {parameterNameB} THEN LEFT({parameterNameA}, LENGTH({parameterNameA}) - 1) ELSE {parameterNameA} END ";
}
public virtual string TrimStart(MethodCallExpressionModel mode)
{
var parameterNameA = mode.Args[0].MemberName;
var parameterNameB = mode.Args[1].MemberName;
return $" LTRIM(BOTH " + parameterNameB + " FROM " + parameterNameA + ") ";
return @$" CASE WHEN LEFT({parameterNameA}, 1) = {parameterNameB} THEN RIGHT({parameterNameA}, LEN({parameterNameA}) - 1) ELSE {parameterNameA} END ";
}
}
}

24
Src/Asp.NetCore2/SqlSugar/Realization/MySql/SqlBuilder/MySqlExpressionContext.cs

@ -245,18 +245,18 @@ namespace SqlSugar
return $" JSON_CONTAINS({model.Args[0].MemberName},'{{\"{model.Args[1].MemberValue}\":\"{model.Args[2].MemberValue.ObjToStringNoTrim().ToSqlFilter()}\"}}')";
}
}
public override string TrimEnd(MethodCallExpressionModel mode)
{
var parameterNameA = mode.Args[0].MemberName;
var parameterNameB = mode.Args[1].MemberName;
return $" TRIM(TRAILING {parameterNameA} FROM {parameterNameB}) ";
}
public override string TrimStart(MethodCallExpressionModel mode)
{
//public override string TrimEnd(MethodCallExpressionModel mode)
//{
// var parameterNameA = mode.Args[0].MemberName;
// var parameterNameB = mode.Args[1].MemberName;
// return $" TRIM(TRAILING {parameterNameA} FROM {parameterNameB}) ";
//}
//public override string TrimStart(MethodCallExpressionModel mode)
//{
var parameterNameA = mode.Args[0].MemberName;
var parameterNameB = mode.Args[1].MemberName;
return $" TRIM(LEADING {parameterNameA} FROM {parameterNameB}) ";
}
// var parameterNameA = mode.Args[0].MemberName;
// var parameterNameB = mode.Args[1].MemberName;
// return $" TRIM(LEADING {parameterNameA} FROM {parameterNameB}) ";
//}
}
}

4
Src/Asp.NetCore2/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerExpressionContext.cs

@ -113,14 +113,14 @@ namespace SqlSugar
{
var parameterNameA = mode.Args[0].MemberName;
var parameterNameB = mode.Args[1].MemberName;
return $" RTRIM(REPLACE({parameterNameA}, {parameterNameB}, '')) ";
return $"CASE WHEN RIGHT({parameterNameA}, 1) = {parameterNameB} THEN LEFT({parameterNameA}, LEN({parameterNameA}) - 1) ELSE {parameterNameA} END";
}
public override string TrimStart(MethodCallExpressionModel mode)
{
var parameterNameA = mode.Args[0].MemberName;
var parameterNameB = mode.Args[1].MemberName;
return $" LTRIM(REPLACE({parameterNameA},{parameterNameB}, '')) ";
return $" CASE WHEN LEFT({parameterNameA}, 1) = {parameterNameB} THEN RIGHT({parameterNameA}, LEN({parameterNameA}) - 1) ELSE {parameterNameA} END ";
}
}

Loading…
Cancel
Save