- 完善 $"{a.Code}_{a.Id}" lambda 解析,防止 null 相连;

This commit is contained in:
28810
2020-07-26 09:34:49 +08:00
parent 4a2d30298b
commit e80f179663
30 changed files with 55 additions and 51 deletions

View File

@ -222,7 +222,12 @@ namespace FreeSql.MsAccess
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]} 必须为常量");
var expArgs = exp.Arguments.Where((a, z) => z > 0).Select(a => $"'+{(((a as UnaryExpression)?.Operand.Type ?? a.Type) == typeof(string) ? $"({ExpressionLambdaToSql(a, tsc)})" : $"cstr({ExpressionLambdaToSql(a, tsc)})")}+'").ToArray();
var expArgs = exp.Arguments.Where((a, z) => z > 0).Select(a =>
{
var asql = ((a as UnaryExpression)?.Operand.Type ?? a.Type) == typeof(string) ? $"{ExpressionLambdaToSql(a, tsc)}" : $"cstr({ExpressionLambdaToSql(a, tsc)})";
return $"'+{_common.IsNull(asql, "''")}+'";
}
).ToArray();
return string.Format(ExpressionLambdaToSql(exp.Arguments[0], tsc), expArgs);
}
}