mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	#694 ✨ Exception信息 国际化 多语言
This commit is contained in:
		@@ -31,7 +31,7 @@ namespace FreeSql.Odbc.Dameng
 | 
			
		||||
 | 
			
		||||
            string getMergeSql(List<T1> data)
 | 
			
		||||
            {
 | 
			
		||||
                if (_table.Primarys.Any() == false) throw new Exception($"InsertOrUpdate 功能执行 merge into 要求实体类 {_table.CsName} 必须有主键");
 | 
			
		||||
                if (_table.Primarys.Any() == false) throw new Exception(CoreStrings.InsertOrUpdate_Must_Primary_Key(_table.CsName));
 | 
			
		||||
 | 
			
		||||
                var sb = new StringBuilder().Append("MERGE INTO ").Append(_commonUtils.QuoteSqlName(TableRuleInvoke())).Append(" t1 \r\nUSING (");
 | 
			
		||||
                WriteSourceSelectUnionAll(data, sb, dbParams);
 | 
			
		||||
 
 | 
			
		||||
@@ -266,7 +266,7 @@ namespace FreeSql.Odbc.Dameng
 | 
			
		||||
                    case "Concat":
 | 
			
		||||
                        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]} 必须为常量");
 | 
			
		||||
                        if (exp.Arguments[0].NodeType != ExpressionType.Constant) throw new Exception(CoreStrings.Not_Implemented_Expression_ParameterUseConstant(exp,exp.Arguments[0]));
 | 
			
		||||
                        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 解析出来是分开的
 | 
			
		||||
 
 | 
			
		||||
@@ -328,7 +328,7 @@ namespace FreeSql.Odbc.KingbaseES
 | 
			
		||||
                    case "Concat":
 | 
			
		||||
                        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]} 必须为常量");
 | 
			
		||||
                        if (exp.Arguments[0].NodeType != ExpressionType.Constant) throw new Exception(CoreStrings.Not_Implemented_Expression_ParameterUseConstant(exp,exp.Arguments[0]));
 | 
			
		||||
                        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 解析出来是分开的
 | 
			
		||||
 
 | 
			
		||||
@@ -262,7 +262,7 @@ namespace FreeSql.Odbc.MySql
 | 
			
		||||
                    case "Concat":
 | 
			
		||||
                        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]} 必须为常量");
 | 
			
		||||
                        if (exp.Arguments[0].NodeType != ExpressionType.Constant) throw new Exception(CoreStrings.Not_Implemented_Expression_ParameterUseConstant(exp,exp.Arguments[0]));
 | 
			
		||||
                        if (exp.Arguments.Count == 1) return ExpressionLambdaToSql(exp.Arguments[0], tsc);
 | 
			
		||||
                        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);
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@ namespace FreeSql.Odbc.Oracle
 | 
			
		||||
 | 
			
		||||
            string getMergeSql(List<T1> data)
 | 
			
		||||
            {
 | 
			
		||||
                if (_table.Primarys.Any() == false) throw new Exception($"InsertOrUpdate 功能执行 merge into 要求实体类 {_table.CsName} 必须有主键");
 | 
			
		||||
                if (_table.Primarys.Any() == false) throw new Exception(CoreStrings.InsertOrUpdate_Must_Primary_Key(_table.CsName));
 | 
			
		||||
 | 
			
		||||
                var sb = new StringBuilder().Append("MERGE INTO ").Append(_commonUtils.QuoteSqlName(TableRuleInvoke())).Append(" t1 \r\nUSING (");
 | 
			
		||||
                WriteSourceSelectUnionAll(data, sb, dbParams);
 | 
			
		||||
 
 | 
			
		||||
@@ -266,7 +266,7 @@ namespace FreeSql.Odbc.Oracle
 | 
			
		||||
                    case "Concat":
 | 
			
		||||
                        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]} 必须为常量");
 | 
			
		||||
                        if (exp.Arguments[0].NodeType != ExpressionType.Constant) throw new Exception(CoreStrings.Not_Implemented_Expression_ParameterUseConstant(exp,exp.Arguments[0]));
 | 
			
		||||
                        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 解析出来是分开的
 | 
			
		||||
 
 | 
			
		||||
@@ -350,7 +350,7 @@ namespace FreeSql.Odbc.PostgreSQL
 | 
			
		||||
                    case "Concat":
 | 
			
		||||
                        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]} 必须为常量");
 | 
			
		||||
                        if (exp.Arguments[0].NodeType != ExpressionType.Constant) throw new Exception(CoreStrings.Not_Implemented_Expression_ParameterUseConstant(exp,exp.Arguments[0]));
 | 
			
		||||
                        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 解析出来是分开的
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@ namespace FreeSql.Odbc.SqlServer
 | 
			
		||||
 | 
			
		||||
            string getMergeSql(List<T1> data)
 | 
			
		||||
            {
 | 
			
		||||
                if (_table.Primarys.Any() == false) throw new Exception($"InsertOrUpdate 功能执行 merge into 要求实体类 {_table.CsName} 必须有主键");
 | 
			
		||||
                if (_table.Primarys.Any() == false) throw new Exception(CoreStrings.InsertOrUpdate_Must_Primary_Key(_table.CsName));
 | 
			
		||||
 | 
			
		||||
                var sb = new StringBuilder();
 | 
			
		||||
                if (IdentityColumn != null) sb.Append("SET IDENTITY_INSERT ").Append(_commonUtils.QuoteSqlName(TableRuleInvoke())).Append(" ON;\r\n");
 | 
			
		||||
 
 | 
			
		||||
@@ -272,7 +272,7 @@ namespace FreeSql.Odbc.SqlServer
 | 
			
		||||
                    case "Concat":
 | 
			
		||||
                        return _common.StringConcat(exp.Arguments.Select(a => getExp(a)).ToArray(), exp.Arguments.Select(a => a.Type).ToArray());
 | 
			
		||||
                    case "Format":
 | 
			
		||||
                        if (exp.Arguments[0].NodeType != ExpressionType.Constant) throw new Exception($"未实现函数表达式 {exp} 解析,参数 {exp.Arguments[0]} 必须为常量");
 | 
			
		||||
                        if (exp.Arguments[0].NodeType != ExpressionType.Constant) throw new Exception(CoreStrings.Not_Implemented_Expression_ParameterUseConstant(exp,exp.Arguments[0]));
 | 
			
		||||
                        var expArgs0 = ExpressionLambdaToSql(exp.Arguments[0], tsc);
 | 
			
		||||
                        if (exp.Arguments.Count == 1) return expArgs0;
 | 
			
		||||
                        var nchar = expArgs0.StartsWith("N'") ? "N" : "";
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user