- 完善 $"{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

@ -263,10 +263,10 @@ namespace FreeSql.SqlServer
var expArgs = exp.Arguments.Where((a, z) => z > 0).Select(a =>
{
var atype = (a as UnaryExpression)?.Operand.Type.NullableTypeOrThis() ?? a.Type.NullableTypeOrThis();
if (atype == typeof(string)) return $"'+({ExpressionLambdaToSql(a, tsc)})+{nchar}'";
if (atype == typeof(Guid)) return $"'+cast({ExpressionLambdaToSql(a, tsc)} as char(36))+{nchar}'";
if (atype.IsNumberType()) return $"'+cast({ExpressionLambdaToSql(a, tsc)} as varchar)+{nchar}'";
return $"'+cast({ExpressionLambdaToSql(a, tsc)} as nvarchar(max))+{nchar}'";
if (atype == typeof(string)) return $"'+{_common.IsNull(ExpressionLambdaToSql(a, tsc), "''")}+{nchar}'";
if (atype == typeof(Guid)) return $"'+{_common.IsNull($"cast({ExpressionLambdaToSql(a, tsc)} as char(36))", "''")}+{nchar}'";
if (atype.IsNumberType()) return $"'+{_common.IsNull($"cast({ExpressionLambdaToSql(a, tsc)} as varchar)", "''")}+{nchar}'";
return $"'+{_common.IsNull($"cast({ExpressionLambdaToSql(a, tsc)} as nvarchar(max))", "''")}+{nchar}'";
}).ToArray();
return string.Format(expArgs0, expArgs);
}