Beispiel #1
0
        private void GenericUpdate(ExprTable targetIn, IReadOnlyList <ExprColumnSetClause> sets, IExprTableSource?source, ExprBoolean?filter, IExpr?parent)
        {
            this.AssertNotEmptyList(sets, "'UPDATE' statement should have at least one set clause");

            IExprColumnSource target = targetIn.FullName;

            if (targetIn.Alias != null)
            {
                target = targetIn.Alias;
                source ??= targetIn;
            }

            this.Builder.Append("UPDATE ");
            target.Accept(this, parent);

            this.Builder.Append(" SET ");
            this.AcceptListComaSeparated(sets, parent);

            if (source != null)
            {
                this.Builder.Append(" FROM ");
                source.Accept(this, parent);
            }
            if (filter != null)
            {
                this.Builder.Append(" WHERE ");
                filter.Accept(this, parent);
            }
        }
Beispiel #2
0
        private void GenericDelete(ExprTable targetIn, IReadOnlyList <ExprAliasedColumn>?output, IExprTableSource?source, ExprBoolean?filter, IExpr?parent)
        {
            IExprColumnSource target = targetIn.FullName;

            if (targetIn.Alias != null)
            {
                target = targetIn.Alias;
                source ??= targetIn;
            }

            this.Builder.Append("DELETE ");
            target.Accept(this, parent);

            if (output != null)
            {
                this.AssertNotEmptyList(output, "Output list in 'DELETE' statement cannot be empty");
                this.Builder.Append(" OUTPUT ");
                for (int i = 0; i < output.Count; i++)
                {
                    if (i != 0)
                    {
                        this.Builder.Append(',');
                    }

                    this.Builder.Append("DELETED.");

                    var col = output[i];

                    if (col.Column.Source == null)
                    {
                        col.Accept(this, parent);
                    }
                    else
                    {
                        new ExprAliasedColumnName(col.Column.ColumnName, col.Alias).Accept(this, parent);
                    }
                }
            }

            if (source != null)
            {
                this.Builder.Append(" FROM ");
                source.Accept(this, parent);
            }
            if (filter != null)
            {
                this.Builder.Append(" WHERE ");
                filter.Accept(this, parent);
            }
        }
Beispiel #3
0
 public static ExprColumn Column(IExprColumnSource source, string columnName)
 => new ExprColumn(source, columnName);