mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
- 增加 Firebird string.Join + ToList 表达式解析,实现与 MySql group_concat 相同的效果 #443;
This commit is contained in:
parent
7e2903df22
commit
7240181ff5
@ -53,7 +53,7 @@ namespace FreeSql.Tests.FirebirdExpression
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void StringJoin()
|
public void StringJoin()
|
||||||
{
|
{
|
||||||
var fsql = g.sqlite;
|
var fsql = g.firebird;
|
||||||
fsql.Delete<StringJoin01>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<StringJoin01>().Where("1=1").ExecuteAffrows();
|
||||||
fsql.Insert(new[] { new StringJoin01 { name = "北京" }, new StringJoin01 { name = "上海" }, new StringJoin01 { name = "深圳" }, }).ExecuteAffrows();
|
fsql.Insert(new[] { new StringJoin01 { name = "北京" }, new StringJoin01 { name = "上海" }, new StringJoin01 { name = "深圳" }, }).ExecuteAffrows();
|
||||||
|
|
||||||
|
@ -358,6 +358,11 @@ namespace FreeSql
|
|||||||
expContext.Result = $"listagg(to_char({expContext.ParsedContent["column"]}),{expContext.ParsedContent["delimiter"]}) within group({orderby})";
|
expContext.Result = $"listagg(to_char({expContext.ParsedContent["column"]}),{expContext.ParsedContent["delimiter"]}) within group({orderby})";
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public static string StringJoinFirebirdList(object column, object delimiter)
|
||||||
|
{
|
||||||
|
expContext.Result = $"list({expContext.ParsedContent["column"]},{expContext.ParsedContent["delimiter"]})";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -255,6 +255,20 @@ namespace FreeSql.Firebird
|
|||||||
//4个 {} 时,Arguments[1] 只能解析这个出来,然后里面是 NewArray []
|
//4个 {} 时,Arguments[1] 只能解析这个出来,然后里面是 NewArray []
|
||||||
var expArgs = expArgsHack.Select(a => $"'||{_common.IsNull(ExpressionLambdaToSql(a, tsc), "''")}||'").ToArray();
|
var expArgs = expArgsHack.Select(a => $"'||{_common.IsNull(ExpressionLambdaToSql(a, tsc), "''")}||'").ToArray();
|
||||||
return string.Format(ExpressionLambdaToSql(exp.Arguments[0], tsc), expArgs);
|
return string.Format(ExpressionLambdaToSql(exp.Arguments[0], tsc), expArgs);
|
||||||
|
case "Join":
|
||||||
|
if (exp.IsStringJoin(out var tolistObjectExp, out var toListMethod, out var toListArgs1))
|
||||||
|
{
|
||||||
|
var newToListArgs0 = Expression.Call(tolistObjectExp, toListMethod,
|
||||||
|
Expression.Lambda(
|
||||||
|
Expression.Call(
|
||||||
|
typeof(SqlExtExtensions).GetMethod("StringJoinFirebirdList"),
|
||||||
|
Expression.Convert(toListArgs1.Body, typeof(object)),
|
||||||
|
Expression.Convert(exp.Arguments[0], typeof(object))),
|
||||||
|
toListArgs1.Parameters));
|
||||||
|
var newToListSql = getExp(newToListArgs0);
|
||||||
|
return newToListSql;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user