Пример #1
0
        public override void Visit(WBeginEndBlockStatement node)
        {
            for (int i = 0; i < node.StatementList.Count; i++)
            {
                var statement = node.StatementList[i];

                if (statement is WSelectStatement)
                {
                    var sqlSelect = statement as WSelectStatement;
                    node.StatementList[i] = ConvertSqlSelectStatement(sqlSelect);
                }
                else if (statement is WInsertSpecification)
                {
                    var sqlInsert = statement as WInsertSpecification;
                    node.StatementList[i] = ConvertSqlInsertStatement(sqlInsert);
                }
                else if (statement is WDeleteSpecification)
                {
                    var sqlDelete = statement as WDeleteSpecification;
                    node.StatementList[i] = ConvertSqlDeleteStatement(sqlDelete);
                }
                else
                {
                    statement.Accept(this);
                }
            }
        }
Пример #2
0
 public virtual void Visit(WBeginEndBlockStatement node)
 {
     node.AcceptChildren(this);
 }
Пример #3
0
        private WSqlStatement ParseStatement(TSqlStatement tsqlStat)
        {
            WSqlStatement wstat;

            switch (tsqlStat.GetType().Name)
            {
                case "SelectStatement":
                    {
                        var sel = tsqlStat as SelectStatement;
                        wstat = ParseSelectQueryStatement(sel.QueryExpression);

                        break;
                    }
                case "CreateFunctionStatement":
                    {
                        var creat = tsqlStat as CreateFunctionStatement;
                        var wcreat = new WCreateFunctionStatement
                        {
                            Parameters = creat.Parameters,
                            ReturnType = creat.ReturnType,
                            StatementList = new List<WSqlStatement>(creat.StatementList.Statements.Count),
                            FirstTokenIndex = creat.FirstTokenIndex,
                            LastTokenIndex = creat.LastTokenIndex,
                            Name = ParseSchemaObjectName(creat.Name)
                        };

                        foreach (var stat in creat.StatementList.Statements)
                        {
                            wcreat.StatementList.Add(ParseStatement(stat));
                        }

                        wstat = wcreat;
                        break;
                    }
                case "BeginEndBlockStatement":
                    {
                        var bestat = tsqlStat as BeginEndBlockStatement;
                        var wbestat = new WBeginEndBlockStatement
                        {
                            StatementList = new List<WSqlStatement>(bestat.StatementList.Statements.Count),
                            FirstTokenIndex = bestat.FirstTokenIndex,
                            LastTokenIndex = bestat.LastTokenIndex
                        };

                        foreach (var pstat in bestat.StatementList.Statements.Select(ParseStatement))
                        {
                            wbestat.StatementList.Add(pstat);
                        }

                        wstat = wbestat;
                        break;
                    }
                case "UpdateStatement":
                    {
                        var upd = tsqlStat as UpdateStatement;
                        wstat = ParseUpdateStatement(upd.UpdateSpecification);
                        break;
                    }
                case "DeleteStatement":
                    {
                        var del = tsqlStat as DeleteStatement;
                        wstat = ParseDeleteStatement(del.DeleteSpecification);
                        break;
                    }
                case "InsertStatement":
                    {
                        var ins = tsqlStat as InsertStatement;
                        wstat = ParseInsertStatement(ins.InsertSpecification);
                        break;
                    }
                case "CreateTableStatement":
                    {
                        var cts = tsqlStat as CreateTableStatement;
                        var wcstat = new WCreateTableStatement
                        {
                            FirstTokenIndex = cts.FirstTokenIndex,
                            LastTokenIndex = cts.LastTokenIndex,
                            Definition = ParseTableDefinition(cts.Definition),
                            SchemaObjectName = ParseSchemaObjectName(cts.SchemaObjectName),
                        };
                        wstat = wcstat;
                        break;
                    }
                case "DropTableStatement":
                    {
                        var dts = tsqlStat as DropTableStatement;
                        var wdstat = new WDropTableStatement
                        {
                            FirstTokenIndex = dts.FirstTokenIndex,
                            LastTokenIndex = dts.LastTokenIndex,
                        };
                        if (dts.Objects != null)
                        {
                            wdstat.Objects = new List<WSchemaObjectName>();
                            foreach (var obj in dts.Objects)
                            {
                                wdstat.Objects.Add(ParseSchemaObjectName(obj));
                            }
                        }
                        wstat = wdstat;
                        break;
                    }
                case "CreateViewStatement":
                {
                    var cvs = tsqlStat as CreateViewStatement;
                    var wcvs = new WCreateViewStatement
                    {
                        Columns = cvs.Columns,
                        FirstTokenIndex = cvs.FirstTokenIndex,
                        LastTokenIndex = cvs.LastTokenIndex,
                        SchemaObjectName = ParseSchemaObjectName(cvs.SchemaObjectName),
                        SelectStatement = ParseSelectQueryStatement(cvs.SelectStatement.QueryExpression),
                        ViewOptions = cvs.ViewOptions,
                        WithCheckOption = cvs.WithCheckOption
                    };
                    wstat = wcvs;
                    break;
                }
                case "BeginTransactionStatement":
                    {
                        var beginTranStat = tsqlStat as BeginTransactionStatement;
                        wstat = new WBeginTransactionStatement
                        {
                            Name = ParseIdentifierOrValueExpression(beginTranStat.Name),
                            Distributed = beginTranStat.Distributed,
                            FirstTokenIndex = beginTranStat.FirstTokenIndex,
                            LastTokenIndex = beginTranStat.LastTokenIndex
                        };
                        break;
                    }
                case "CommitTransactionStatement":
                    {

                        var commitTranStat = tsqlStat as CommitTransactionStatement;
                        wstat = new WCommitTransactionStatement
                        {
                            Name = ParseIdentifierOrValueExpression(commitTranStat.Name),
                            FirstTokenIndex = commitTranStat.FirstTokenIndex,
                            LastTokenIndex = commitTranStat.LastTokenIndex
                        };
                        break;
                    }
                case "RollbackTransactionStatement":
                    {

                        var rollbackTranStat = tsqlStat as RollbackTransactionStatement;
                        wstat = new WRollbackTransactionStatement
                        {
                            Name = ParseIdentifierOrValueExpression(rollbackTranStat.Name),
                            FirstTokenIndex = rollbackTranStat.FirstTokenIndex,
                            LastTokenIndex = rollbackTranStat.LastTokenIndex
                        };
                        break;
                    }
                case "SaveTransactionStatement":
                    {

                        var saveTranStat = tsqlStat as SaveTransactionStatement;
                        wstat = new WSaveTransactionStatement
                        {
                            Name = ParseIdentifierOrValueExpression(saveTranStat.Name),
                            FirstTokenIndex = saveTranStat.FirstTokenIndex,
                            LastTokenIndex = saveTranStat.LastTokenIndex
                        };
                        break;
                    }
                case "CreateProcedureStatement":
                    {
                        var creat = tsqlStat as CreateProcedureStatement;
                        var wcreat = new WCreateProcedureStatement
                        {
                            IsForReplication = creat.IsForReplication,
                            Parameters = creat.Parameters,
                            StatementList = new List<WSqlStatement>(creat.StatementList.Statements.Count),
                            FirstTokenIndex = creat.FirstTokenIndex,
                            LastTokenIndex = creat.LastTokenIndex,
                            ProcedureReference = new WProcedureReference
                            {
                                Name = ParseSchemaObjectName(creat.ProcedureReference.Name),
                                Number = creat.ProcedureReference.Number
                            }
                        };

                        foreach (var stat in creat.StatementList.Statements)
                        {
                            wcreat.StatementList.Add(ParseStatement(stat));
                        }

                        wstat = wcreat;
                        break;
                    }
                case "DropProcedureStatement":
                    {
                        var dts = tsqlStat as DropProcedureStatement;
                        var wdstat = new WDropProcedureStatement
                        {
                            FirstTokenIndex = dts.FirstTokenIndex,
                            LastTokenIndex = dts.LastTokenIndex,
                        };
                        if (dts.Objects != null)
                        {
                            wdstat.Objects = new List<WSchemaObjectName>();
                            foreach (var obj in dts.Objects)
                            {
                                wdstat.Objects.Add(ParseSchemaObjectName(obj));
                            }
                        }
                        wstat = wdstat;
                        break;
                    }
                case "WhileStatement":
                    {
                        var bestat = tsqlStat as WhileStatement;
                        var wbestat = new WWhileStatement()
                        {
                            Predicate = ParseBooleanExpression(bestat.Predicate),
                            Statement = ParseStatement(bestat.Statement),
                            FirstTokenIndex = bestat.FirstTokenIndex,
                            LastTokenIndex = bestat.LastTokenIndex
                        };


                        wstat = wbestat;
                        break;
                    }
                case "DeclareVariableStatement":
                {
                    var dvstat = tsqlStat as DeclareVariableStatement;
                    wstat = new WDeclareVariableStatement
                    {
                        Statement = dvstat
                    };
                    break;
                }
                default:
                    {
                        wstat = new WSqlUnknownStatement(tsqlStat)
                        {
                            FirstTokenIndex = tsqlStat.FirstTokenIndex,
                            LastTokenIndex = tsqlStat.LastTokenIndex
                        };

                        break;
                    }
            }

            return wstat;
        }
 public override void Visit(WBeginEndBlockStatement node)
 {
     base.Visit(node);
     node.StatementList = Translate(node.StatementList);
 }
Пример #5
0
 public virtual void Visit(WBeginEndBlockStatement node)
 {
     node.AcceptChildren(this);
 }
        public override void Visit(WBeginEndBlockStatement node)
        {
            for (int i = 0; i < node.StatementList.Count; i++)
            {
                var statement = node.StatementList[i];

                if (statement is WSelectStatement)
                {
                    var sqlSelect = statement as WSelectStatement;
                    node.StatementList[i] = ConvertSqlSelectStatement(sqlSelect);
                }
                else if (statement is WInsertSpecification)
                {
                    var sqlInsert = statement as WInsertSpecification;
                    node.StatementList[i] = ConvertSqlInsertStatement(sqlInsert);
                }
                else if (statement is WDeleteSpecification)
                {
                    var sqlDelete = statement as WDeleteSpecification;
                    node.StatementList[i] = ConvertSqlDeleteStatement(sqlDelete);
                }
                else
                {
                    statement.Accept(this);
                }
            }
        }
Пример #7
0
 public override void Visit(WBeginEndBlockStatement node)
 {
     base.Visit(node);
     ConvertToGraphModificationStatement(node.StatementList);
 }
 public override void Visit(WBeginEndBlockStatement node)
 {
     base.Visit(node);
     ConvertToGraphModificationStatement(node.StatementList);
 }