mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- 优化 string Contains 模糊查找 % 的情况;
This commit is contained in:
		@@ -128,7 +128,7 @@ namespace FreeSql.ShenTong
 | 
			
		||||
                                tsc.SetMapColumnTmp(null);
 | 
			
		||||
                                var args1 = getExp(callExp.Arguments[argIndex]);
 | 
			
		||||
                                var oldMapType = tsc.SetMapTypeReturnOld(tsc.mapTypeTmp);
 | 
			
		||||
                                var oldDbParams = objExp.NodeType == ExpressionType.MemberAccess ? tsc.SetDbParamsReturnOld(null) : null; //#900 UseGenerateCommandParameterWithLambda(true) 子查询 bug、以及 #1173 参数化 bug
 | 
			
		||||
                                var oldDbParams = objExp?.NodeType == ExpressionType.MemberAccess ? tsc.SetDbParamsReturnOld(null) : null; //#900 UseGenerateCommandParameterWithLambda(true) 子查询 bug、以及 #1173 参数化 bug
 | 
			
		||||
                                tsc.isNotSetMapColumnTmp = true;
 | 
			
		||||
                                left = objExp == null ? null : getExp(objExp);
 | 
			
		||||
                                tsc.isNotSetMapColumnTmp = false;
 | 
			
		||||
@@ -345,6 +345,12 @@ namespace FreeSql.ShenTong
 | 
			
		||||
                    case "Contains":
 | 
			
		||||
                        var args0Value = getExp(exp.Arguments[0]);
 | 
			
		||||
                        if (args0Value == "NULL") return $"({left}) IS NULL";
 | 
			
		||||
                        if (args0Value.Contains("%"))
 | 
			
		||||
                        {
 | 
			
		||||
                            if (exp.Method.Name == "StartsWith") return $"strpos({args0Value}, {left}) = 1";
 | 
			
		||||
                            if (exp.Method.Name == "EndsWith") return $"strpos({args0Value}, {left}) = char_length({args0Value})";
 | 
			
		||||
                            return $"strpos({args0Value}, {left}) > 0";
 | 
			
		||||
                        }
 | 
			
		||||
                        var likeOpt = "LIKE";
 | 
			
		||||
                        if (exp.Arguments.Count > 1)
 | 
			
		||||
                        {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user