internal static CqtExpression ConcatArgs(ExpressionConverter parent, Expression linq, Expression[] linqArgs)
{
var args = linqArgs
.Where(arg => !arg.IsNullConstant()) // remove null constants
.Select(arg => ConvertToString(parent, arg)) // Apply ToString semantics
.ToArray();
//if all args was null constants, optimize the entire expression to constant ""
// e.g null + null + null == ""
if (args.Length == 0)
{
return DbExpressionBuilder.Constant(string.Empty);
}
var current = args.First();
foreach (var next in args.Skip(1)) //concat all args
{
current = parent.CreateCanonicalFunction(Concat, linq, current, next);
}
return current;
}