Exemplo n.º 1
0
        private void ProcessTableReference(TableReference TableRef)
        {
            string Type = GetFragmentType(TableRef);

            switch (Type)
            {
            case "FullTextTableReference":
                break;

            case "NamedTableReference":
                var    NamedTableRef = (NamedTableReference)TableRef;
                var    Naming        = NamedTableRef.SchemaObject;
                string ObjectName    = (Naming.DatabaseIdentifier == null ? this.databaseName : Naming.DatabaseIdentifier.Value) + "." +
                                       (Naming.SchemaIdentifier == null ? this.schemaName : Naming.SchemaIdentifier.Value) + "." +
                                       (Naming.BaseIdentifier == null ? "" : Naming.BaseIdentifier.Value);
                addSourcetoCurrentObject(ObjectName);

                break;

            case "QueryDerivedTable":
                QueryDerivedTable qdt = (QueryDerivedTable)TableRef;
                ProcessQueryExpression(qdt.QueryExpression);
                break;

            case "QualifiedJoin":
                QualifiedJoin qj = (QualifiedJoin)TableRef;
                ProcessTableReference(qj.FirstTableReference);
                ProcessTableReference(qj.SecondTableReference);
                break;

            case "UnqualifiedJoin":
                UnqualifiedJoin uqj = (UnqualifiedJoin)TableRef;
                ProcessTableReference(uqj.FirstTableReference);
                ProcessTableReference(uqj.SecondTableReference);
                break;

            case "SchemaObjectFunctionTableReference":
                SchemaObjectFunctionTableReference ftr = (SchemaObjectFunctionTableReference)TableRef;
                break;

            case "PivotedTableReference":
                PivotedTableReference pvt = (PivotedTableReference)TableRef;
                ProcessTableReference(pvt.TableReference);
                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        private void recursifRecuperationProjection(QuerySpecification node)
        {
            bool starExpression = false;

            if (node.SelectElements != null)
            {
                foreach (TSqlFragment selectElement in node.SelectElements)
                {
                    if (selectElement is SelectStarExpression)
                    {
                        starExpression = true;
                        if (node.SelectElements.Count > 1)
                        {
                            //Lever une exception qui dit que c'est non géré*

                            break;
                        }
                        else
                        {
                            if (node.FromClause != null)
                            {
                                foreach (TSqlFragment fromElement in node.FromClause.TableReferences)
                                {
                                    if (fromElement is NamedTableReference)
                                    {
                                        String namedTableReferenceText = GetNodeTokenText(fromElement);
                                        projectionList.AddRange(GetProjectionsFromTablesReference(namedTableReferenceText));
                                    }
                                    if (fromElement is QualifiedJoin)
                                    {
                                        QualifiedJoin currQualifiedJoin = (QualifiedJoin)fromElement;
                                        if (currQualifiedJoin.FirstTableReference is NamedTableReference && currQualifiedJoin.SecondTableReference is NamedTableReference)
                                        {
                                            String namedTableReferenceText1 = GetNodeTokenText(currQualifiedJoin.FirstTableReference);
                                            projectionList.AddRange(GetProjectionsFromTablesReference(namedTableReferenceText1));

                                            String namedTableReferenceText2 = GetNodeTokenText(currQualifiedJoin.SecondTableReference);
                                            projectionList.AddRange(GetProjectionsFromTablesReference(namedTableReferenceText2));
                                        }
                                    }
                                    if (fromElement is PivotedTableReference)
                                    {
                                        PivotedTableReference currPivotedTable = (PivotedTableReference)fromElement;
                                        if (currPivotedTable.TableReference is NamedTableReference)
                                        {
                                            String namedTableReferenceText = GetNodeTokenText(currPivotedTable.TableReference);
                                            projectionList.AddRange(GetProjectionsFromTablesReference(namedTableReferenceText));
                                        }
                                    }
                                    if (fromElement is QueryDerivedTable)
                                    {
                                        QueryDerivedTable currQueryDerivedTable = (QueryDerivedTable)fromElement;
                                        if (currQueryDerivedTable.QueryExpression is QuerySpecification)
                                        {
                                            QuerySpecification currQuerySpecification = (QuerySpecification)currQueryDerivedTable.QueryExpression;
                                            recursifRecuperationProjection(currQuerySpecification);
                                        }
                                        if (currQueryDerivedTable.QueryExpression is BinaryQueryExpression)
                                        {
                                            //BinaryQueryExpression représente un union entre deux requête donc si on veut les projections dans le cas ou
                                            //Il y à un * il faut prendre les projections de la première requête d'union ou intersection
                                            BinaryQueryExpression currBinaryQueryExpression = (BinaryQueryExpression)currQueryDerivedTable.QueryExpression;


                                            while (currBinaryQueryExpression.FirstQueryExpression is BinaryQueryExpression)
                                            {
                                                currBinaryQueryExpression = (BinaryQueryExpression)currBinaryQueryExpression.FirstQueryExpression;
                                            }
                                            if (currBinaryQueryExpression.FirstQueryExpression is QuerySpecification)
                                            {
                                                QuerySpecification currQuerySpecification = (QuerySpecification)currBinaryQueryExpression.FirstQueryExpression;
                                                recursifRecuperationProjection(currQuerySpecification);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (starExpression == false)
                {
                    foreach (SelectElement selectElement in node.SelectElements)
                    {
                        projectionList.Add(GetNodeTokenText(selectElement));
                    }
                }
            }
        }
Exemplo n.º 3
0
 public override void Visit(PivotedTableReference node) { this.action(node); }
 public override void ExplicitVisit(PivotedTableReference fragment)
 {
     _fragments.Add(fragment);
 }
Exemplo n.º 5
0
 public QsiTableNode VisitPivotedTableReference(PivotedTableReference pivotedTableReference)
 {
     // TODO: Implement
     throw TreeHelper.NotSupportedFeature("Pivot table");
 }