mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 增加 SqlServer lambda 表达式树解析子查询 ToList + string.Join() 产生 类似 group_concat 的效果;#405
This commit is contained in:
@ -283,6 +283,24 @@ namespace FreeSql.SqlServer
|
||||
return $"'+{_common.IsNull($"cast({ExpressionLambdaToSql(a, tsc)} as nvarchar(max))", "''")}+{nchar}'";
|
||||
}).ToArray();
|
||||
return string.Format(expArgs0, expArgs);
|
||||
case "Join":
|
||||
if (exp.IsStringJoin(out var joinExpArgs1, out var joinExpArgs1Args0))
|
||||
{
|
||||
var newToListArgs0 = Expression.Call(joinExpArgs1.Object, joinExpArgs1.Method,
|
||||
Expression.Lambda(
|
||||
Expression.Call(
|
||||
typeof(string).GetMethod("Concat", new[] { typeof(object), typeof(object) }),
|
||||
Expression.Convert(joinExpArgs1Args0.Body, typeof(object)),
|
||||
Expression.Convert(exp.Arguments[0], typeof(object))),
|
||||
joinExpArgs1Args0.Parameters));
|
||||
var newToListSql = getExp(newToListArgs0);
|
||||
if (string.IsNullOrEmpty(newToListSql) == false && newToListSql.StartsWith("(") && newToListSql.EndsWith(")"))
|
||||
{
|
||||
newToListSql = $"{newToListSql.Substring(0, newToListSql.Length - 1)} FOR XML PATH(''))";
|
||||
return newToListSql;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user