mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- 修复 $"{a.Code}_{a.Id}" lambda 解析当 {} 多于3个时的 bug(.net 内部机制很坑);
> 3个 {} 时,Arguments[1..3] 解析出来是分开的
> 4个 {} 时,Arguments[1] 只能解析这个出来,然后 [1] 里面是 NewArray []
			
			
This commit is contained in:
		@@ -252,7 +252,11 @@ namespace FreeSql.Odbc.Dameng
 | 
			
		||||
                        return _common.StringConcat(exp.Arguments.Select(a => getExp(a)).ToArray(), null);
 | 
			
		||||
                    case "Format":
 | 
			
		||||
                        if (exp.Arguments[0].NodeType != ExpressionType.Constant) throw new Exception($"未实现函数表达式 {exp} 解析,参数 {exp.Arguments[0]} 必须为常量");
 | 
			
		||||
                        var expArgs = exp.Arguments.Where((a, z) => z > 0).Select(a => $"'||{_common.IsNull(ExpressionLambdaToSql(a, tsc), "''")}||'").ToArray();
 | 
			
		||||
                        var expArgsHack = exp.Arguments.Count == 2 && exp.Arguments[1].NodeType == ExpressionType.NewArrayInit ?
 | 
			
		||||
                            (exp.Arguments[1] as NewArrayExpression).Expressions : exp.Arguments.Where((a, z) => z > 0);
 | 
			
		||||
                        //3个 {} 时,Arguments 解析出来是分开的
 | 
			
		||||
                        //4个 {} 时,Arguments[1] 只能解析这个出来,然后里面是 NewArray []
 | 
			
		||||
                        var expArgs = expArgsHack.Select(a => $"'||{_common.IsNull(ExpressionLambdaToSql(a, tsc), "''")}||'").ToArray();
 | 
			
		||||
                        return string.Format(ExpressionLambdaToSql(exp.Arguments[0], tsc), expArgs);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user