- 修复 .Contains('b%') 部分数据库函数参数位置错误;#1826

This commit is contained in:
2881099
2024-06-19 15:10:11 +08:00
parent 6bf4c21af0
commit 20b88248e9
23 changed files with 53 additions and 54 deletions

View File

@ -339,7 +339,7 @@ namespace FreeSql.Custom.SqlServer
if (args0Value.Contains("%"))
{
if (exp.Method.Name == "StartsWith") return $"charindex({args0Value}, {left}) = 1";
if (exp.Method.Name == "EndsWith") return $"charindex({args0Value}, {left}) = len({args0Value})";
if (exp.Method.Name == "EndsWith") return $"charindex({args0Value}, {left}) = len({left})-len({args0Value})+1";
return $"charindex({args0Value}, {left}) > 0";
}
if (exp.Method.Name == "StartsWith") return $"({left}) LIKE {(args0Value.EndsWith("'") ? args0Value.Insert(args0Value.Length - 1, "%") : $"(cast({args0Value} as nvarchar(max))+'%')")}";