Ejemplo n.º 1
0
        public bool VisitExprTableValueConstructor(ExprTableValueConstructor tableValueConstructor, IExpr?parent)
        {
            this.Builder.Append("VALUES ");

            var nullCast = CheckForNullColCast(tableValueConstructor.Items);

            for (var rowIndex = 0; rowIndex < tableValueConstructor.Items.Count; rowIndex++)
            {
                var rowValue = tableValueConstructor.Items[rowIndex];

                if (rowIndex > 0)
                {
                    this.Builder.Append(',');
                }
                else
                {
                    if (nullCast != null)
                    {
                        var newItems = rowValue
                                       .Items
                                       .Select((item, index) =>
                        {
                            var exprType = nullCast[index];
                            return(exprType == null ? item : SqQueryBuilder.Cast(item, exprType));
                        })
                                       .ToList();
                        rowValue = rowValue.WithItems(newItems);
                    }
                }

                rowValue.Accept(this, tableValueConstructor);
            }

            return(true);