Ejemplo n.º 1
0
 public void UpdateTopPercentTable(SqlFragment parent, UpdateTopPercentTable updateTopPercentTable)
 {
     this.Script.Append(TSqlKeyword.UPDATE_TOP).OpenParen();
     this.Script.AppendFragment(updateTopPercentTable.TopPercent, parent, this);
     this.Script.CloseParen().Append(TSqlKeyword.PERCENT);
     this.Script.AppendFragment(updateTopPercentTable.Table, parent, this);
 }
Ejemplo n.º 2
0
 public void LeftOuterJoin <T>(SqlFragment parent, LeftOuterJoin <T> leftOuterJoin) where T : IStatement
 {
     this.Script.Append(TSqlKeyword.LEFT_OUTER_JOIN);
     this.Script.AppendFragment(leftOuterJoin.Table, parent, this);
     this.Script.Append(TSqlKeyword.ON);
     this.Script.AppendFragment(leftOuterJoin.OnPredicate, parent, this);
 }
Ejemplo n.º 3
0
 public void NotInValuesPredicate(SqlFragment parent, NotInValuesPredicate notInValuesPredicate)
 {
     notInValuesPredicate.Expression.Build(parent, this);
     this.Script.Append("NOT IN(");
     ExpressionFormatter.FormatExpressionList(notInValuesPredicate.Values, notInValuesPredicate, this.Script, this);
     this.Script.Append(")");
 }
Ejemplo n.º 4
0
 public void NotInSingleExprSelectStatementPredicate(SqlFragment parent, NotInSingleExprSelectStatementPredicate element)
 {
     element.Expression.Build(parent, this);
     this.Script.Append("NOT IN(");
     this.Script.AppendFragment(element.SingleExpressionSelectStatement.FirstFragment, element, this);
     this.Script.Append(")");
 }
Ejemplo n.º 5
0
 public void SelectDistinctTopPercent <T>(SqlFragment parent, SelectDistinctTopPercent <T> selectDistinctTopPercent) where T : IStatement
 {
     this.Script.Append("SELECT DISTINCT TOP (");
     this.Script.AppendFragment(selectDistinctTopPercent.Percent, parent, this);
     this.Script.Append(") PERCENT");
     ExpressionFormatter.FormatExpressionList(selectDistinctTopPercent.ColumnList, parent, this.Script, this);
 }
Ejemplo n.º 6
0
        public void Table(SqlFragment parent, Table table)
        {
            if (parent is DeleteClause)
            {
                this.Script.AppendFormat("[{0}].[{1}]", table.Scheme, table.TableName);
                return;
            }

            if (parent is UpdateClause && table.Alias != null)
            {
                this.Script.AppendFormat("[{0}]", table.Alias);
                return;
            }

            if (table.Alias != null)
            {
                if (parent is Column)
                {
                    this.Script.AppendFormat("[{0}]", table.Alias);
                }
                else
                {
                    this.Script.AppendFormat("[{0}].[{1}] AS [{2}]", table.Scheme, table.TableName, table.Alias);
                }
            }
            else
            {
                this.Script.AppendFormat("[{0}].[{1}]", table.Scheme, table.TableName);
            }
        }
Ejemplo n.º 7
0
 public void InValuesPredicate(SqlFragment parent, InValuesPredicate inValuesPredicate)
 {
     inValuesPredicate.Expression.Build(parent, this);
     this.Script.Append("IN(");
     ExpressionFormatter.FormatExpressionList(inValuesPredicate.ValueList, inValuesPredicate, this.Script, this);
     this.Script.Append(")");
 }
Ejemplo n.º 8
0
 public void FullOuterJoin <T>(SqlFragment parent, FullOuterJoin <T> fullOuterJoin) where T : IStatement
 {
     this.Script.LineAppend(TSqlKeyword.FULL_OUTER_JOIN);
     this.Script.AppendFragment(fullOuterJoin.Table, parent, this);
     this.Script.Append(TSqlKeyword.ON);
     this.Script.AppendFragment(fullOuterJoin.OnPredicate, parent, this);
 }
Ejemplo n.º 9
0
 public void CrossApply <T>(SqlFragment parent, CrossApply <T> crossApply) where T : IStatement
 {
     this.Script.Append(TSqlKeyword.CROSS_APPLY);
     this.Script.AppendFragment(crossApply.TableValuedFunction, parent, this);
     this.Script.Append(TSqlKeyword.ON);
     this.Script.AppendFragment(crossApply.OnPredicate, parent, this);
 }
Ejemplo n.º 10
0
 public void UpdateTopTable(SqlFragment parent, UpdateTopTable updateTopTable)
 {
     this.Script.Append("UPDATE TOP(");
     this.Script.AppendFragment(updateTopTable.Top, parent, this);
     this.Script.Append(")");
     this.Script.AppendFragment(updateTopTable.Table, parent, this);
 }
Ejemplo n.º 11
0
 public void DeleteTopFromTable(SqlFragment parent, DeleteTopFromTable deleteTopFromTable)
 {
     this.Script.Append("DELETE TOP (");
     this.Script.AppendFragment(deleteTopFromTable.Top, deleteTopFromTable, this);
     this.Script.Append(") FROM");
     this.Script.AppendFragment(deleteTopFromTable.Table, deleteTopFromTable, this);
 }
Ejemplo n.º 12
0
 public void SelectDistinctTop <T>(SqlFragment parent, SelectDistinctTop <T> selectDistinctTop) where T : IStatement
 {
     this.Script.Append("SELECT DISTINCT TOP (");
     this.Script.AppendFragment(selectDistinctTop.Count, parent, this);
     this.Script.Append(")");
     ExpressionFormatter.FormatExpressionList(selectDistinctTop.Columns, parent, this.Script, this);
 }
Ejemplo n.º 13
0
 public void InsertValuesStart(SqlFragment parent, InsertValuesStart insertValuesStart)
 {
     this.Script.AppendLine();
     this.Script.AppendLine("VALUES(");
     ExpressionFormatter.FormatExpressionList(insertValuesStart.ExpressionList, insertValuesStart, this.Script, this);
     this.Script.Append(")");
 }
Ejemplo n.º 14
0
 public void RightOuterJoin <T>(SqlFragment parent, RightOuterJoin <T> rightOuterJoin) where T : IStatement
 {
     this.Script.AppendLine(TSqlKeyword.RIGHT_OUTER_JOIN);
     this.Script.AppendFragment(rightOuterJoin.Table, rightOuterJoin, this);
     this.Script.Append(TSqlKeyword.ON);
     this.Script.AppendFragment(rightOuterJoin.OnPredicate, rightOuterJoin, this);
 }
Ejemplo n.º 15
0
 public void OrConditionalOperator(SqlFragment parent, OrConditionalOperator orConditionalOperator)
 {
     this.Script.OpenParen();
     orConditionalOperator.LeftOperand.Build(parent, this);
     this.Script.Append(TSqlKeyword.OR);
     orConditionalOperator.RightOperand.Build(parent, this);
     this.Script.CloseParen();
 }
Ejemplo n.º 16
0
 public void PlusArithmeticExpressionOperator(SqlFragment parent, PlusArithmeticExpressionOperator plusArithmeticExpressionOperator)
 {
     this.Script.OpenParen();
     plusArithmeticExpressionOperator.LeftOperand.Build(plusArithmeticExpressionOperator, this);
     this.Script.Append("+");
     plusArithmeticExpressionOperator.RightOperand.Build(plusArithmeticExpressionOperator, this);
     this.Script.CloseParen();
 }
Ejemplo n.º 17
0
 public void MultiplyArithmeticExpressionOperator(SqlFragment parent, MultiplyArithmeticExpressionOperator multiplyArithmeticExpressionOperator)
 {
     this.Script.OpenParen();
     multiplyArithmeticExpressionOperator.LeftOperand.Build(multiplyArithmeticExpressionOperator, this);
     this.Script.Append("*");
     multiplyArithmeticExpressionOperator.RightOperand.Build(multiplyArithmeticExpressionOperator, this);
     this.Script.CloseParen();
 }
Ejemplo n.º 18
0
 public void ModuloArithmeticExpressionOperator(SqlFragment parent, ModuloArithmeticExpressionOperator moduloArithmeticExpressionOperator)
 {
     this.Script.OpenParen();
     moduloArithmeticExpressionOperator.LeftOperand.Build(moduloArithmeticExpressionOperator, this);
     this.Script.Append("%");
     moduloArithmeticExpressionOperator.RightOperand.Build(moduloArithmeticExpressionOperator, this);
     this.Script.CloseParen();
 }
Ejemplo n.º 19
0
 public void DivideArithmeticExpressionOperator(SqlFragment parent, DivideArithmeticExpressionOperator divideArithmeticExpressionOperator)
 {
     this.Script.OpenParen();
     divideArithmeticExpressionOperator.LeftOperand.Build(divideArithmeticExpressionOperator, this);
     this.Script.Append("/");
     divideArithmeticExpressionOperator.RightOperand.Build(divideArithmeticExpressionOperator, this);
     this.Script.CloseParen();
 }
Ejemplo n.º 20
0
 public void InnerJoin <T>(SqlFragment parent, InnerJoin <T> innerJoin) where T : IStatement
 {
     this.Script.AppendLine();
     this.Script.Append(TSqlKeyword.INNER_JOIN);
     this.Script.AppendFragment(innerJoin.Table, parent, this);
     this.Script.Append(TSqlKeyword.ON);
     this.Script.AppendFragment(innerJoin.OnPredicate, parent, this);
 }
Ejemplo n.º 21
0
 public void AndConditionalOperator(SqlFragment parent, AndConditionalOperatorAndPredicate andConditionalOperatorAndPredicate)
 {
     this.Script.OpenParen();
     andConditionalOperatorAndPredicate.LeftOperand.Build(parent, this);
     this.Script.Append(TSqlKeyword.AND);
     andConditionalOperatorAndPredicate.RightOperand.Build(parent, this);
     this.Script.CloseParen();
 }
Ejemplo n.º 22
0
 public void CastFunction(SqlFragment parent, CastFunction castFunction)
 {
     this.Script.Append("CAST(");
     castFunction.Expression.Build(castFunction, this);
     this.Script.Append(TSqlKeyword.AS);
     castFunction.Type.Build(castFunction, this);
     this.Script.Append(")");
 }
Ejemplo n.º 23
0
        public void EndsWithPredicate(SqlFragment parent, EndsWithPredicate endsWithPredicate)
        {
            endsWithPredicate.LeftOperand.Build(parent, this);
            this.Script.Append("LIKE");
            Expression expression = "%" + endsWithPredicate.RightOperand;

            expression.Build(parent, this);
        }
Ejemplo n.º 24
0
        public void StartsWithPredicate(SqlFragment parent, StartsWithPredicate startsWithPredicate)
        {
            startsWithPredicate.LeftOperand.Build(startsWithPredicate, this);
            this.Script.Append(TSqlKeyword.LIKE);
            Expression expression = startsWithPredicate.RightOperand + "%";

            expression.Build(startsWithPredicate, this);
        }
Ejemplo n.º 25
0
        public void VisitAsExpression(SqlFragment parent, AsExpression asExpression)
        {
            asExpression.Expression1.Build(parent, this);

            if (parent is OrderBy == false)
            {
                this.Script.AppendFormat(" AS [{0}]", asExpression.Alias);
            }
        }
Ejemplo n.º 26
0
 public void BetweenPredicate(SqlFragment parent, BetweenPredicate element)
 {
     this.Script.OpenParen();
     element.Expression.Build(parent, this);
     this.Script.Append(TSqlKeyword.BETWEEN);
     element.Minimum.Build(parent, this);
     this.Script.Append(TSqlKeyword.AND);
     element.Maximum.Build(parent, this);
     this.Script.CloseParen();
 }
Ejemplo n.º 27
0
 public void DateAddFunction(SqlFragment parent, DateAddFunction dateAddFunction)
 {
     this.Script.Append("DATEADD(");
     this.Script.Append(dateAddFunction.DatePart.ToString());
     this.Script.Append(", ");
     this.Script.AppendFragment(dateAddFunction.Number, dateAddFunction, this);
     this.Script.Append(", ");
     this.Script.AppendFragment(dateAddFunction.Date, dateAddFunction, this);
     this.Script.Append(")");
 }
Ejemplo n.º 28
0
        public void ContainsPredicate(SqlFragment parent, ContainsPredicate containsPredicate)
        {
            // TODO do we keep contains here?
            containsPredicate.LeftOperand.Build(parent, this);
            this.Script.Append("LIKE");

            Expression expression = "%" + containsPredicate.RightOperand + "%";

            expression.Build(parent, this);
        }
Ejemplo n.º 29
0
        internal ScriptBuilder AppendFragment(SqlFragment fragment, SqlFragment parent, TSqlVisitor visitor) {
            SqlFragment v = parent;
            // TODO check here if this is a correct behaviour
            while (fragment != null) {
                fragment.Build(v, visitor);
                v = fragment;
                fragment = fragment.NextFragment;
            }

            return this;
        }
Ejemplo n.º 30
0
        public void InsertAdvancedClause(SqlFragment parent, InsertAdvancedClause insertAdvancedClause)
        {
            this.Script.OpenParen();
            Column[] cols = insertAdvancedClause.Args.Select(v => v.Column).ToArray();
            ExpressionFormatter.FormatColumnList(cols, insertAdvancedClause, this.Script, this);
            this.Script.CloseParen();

            this.Script.Append(TSqlKeyword.VALUES).OpenParen();
            Expression[] values = insertAdvancedClause.Args.Select(v => v.Expression).ToArray();
            ExpressionFormatter.FormatExpressionList(values, insertAdvancedClause, this.Script, this);
            this.Script.CloseParen();
        }
Ejemplo n.º 31
0
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.CastFunction(parent, this);
 }
Ejemplo n.º 32
0
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.UserDefinedFunction(parent, this);
 }
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.VisitScalarSelectStatementExpression(parent, this);
 }
Ejemplo n.º 34
0
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.SimpleCase(parent, this);
 }
Ejemplo n.º 35
0
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.DeleteFromTable(parent, this);
 }
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.DivideArithmeticExpressionOperator(parent, this);
 }
Ejemplo n.º 37
0
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.VisitAsExpression(parent, this);
 }
Ejemplo n.º 38
0
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.StartsWithPredicate(parent, this);
 }
Ejemplo n.º 39
0
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.InsertIntoTableAdvanced(parent, this);
 }
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.InsertTopPercentIntoTable(parent, this);
 }
Ejemplo n.º 41
0
        internal ScriptBuilder AppendFragment(SqlFragment fragment, SqlFragment parent, TSqlVisitor visitor)
        {
            SqlFragment v = parent;
            // TODO check here if this is a correct behaviour
            while (fragment != null) {
                fragment.Build(v, visitor);
                v = fragment;
                fragment = fragment.NextFragment;
            }

            return this;
        }
Ejemplo n.º 42
0
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.InsertValuesStart(parent, this);
 }
Ejemplo n.º 43
0
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.UpdateTopPercentTable(parent, this);
 }
Ejemplo n.º 44
0
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.NextValues(parent, this);
 }
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.VisitRowNumberOverOrderByExpression(parent, this);
 }
Ejemplo n.º 46
0
 public override void Build(SqlFragment parent, TSqlVisitor visitor)
 {
     visitor.Parameter(parent, this);
 }