private BooleanIsNullExpression GetIsNotNull()
        {
            var isNull = new BooleanIsNullExpression();
            isNull.IsNot = true;
            var query = (isNull.Expression = new ScalarSubquery()) as ScalarSubquery;
            var spec = (query.QueryExpression = new QuerySpecification()) as QuerySpecification;
            spec.SelectElements.Add(new SelectStarExpression());
            var fromTable = new QueryDerivedTable();
            spec.FromClause = new FromClause();
            spec.FromClause.TableReferences.Add(fromTable);
            var subQuerySpec = new QuerySpecification();
            var version = new GlobalVariableExpression();
            version.Name = "@@version";

            var columnName = new IdentifierOrValueExpression();
            //var v = (columnName.ValueExpression = new StringLiteral()) as StringLiteral;
            //v.Value = "v";
            columnName.Identifier = new Identifier();
            columnName.Identifier.Value = "v";

            subQuerySpec.SelectElements.Add(new SelectScalarExpression {Expression = version, ColumnName = columnName});
            fromTable.QueryExpression = subQuerySpec;
            fromTable.Alias = new Identifier {Value = "edition"};

            spec.WhereClause = new WhereClause();
            var likePredicate = (spec.WhereClause.SearchCondition = new LikePredicate()) as LikePredicate;
            var col = (likePredicate.FirstExpression = new ColumnReferenceExpression()) as ColumnReferenceExpression;
            col.ColumnType = ColumnType.Regular;
            col.MultiPartIdentifier = new MultiPartIdentifier();
            col.MultiPartIdentifier.Identifiers.Add(new Identifier {Value = "v"});
            var ver = (likePredicate.SecondExpression = new StringLiteral()) as StringLiteral;
            ver.Value = "%Enterprise%";

            return isNull;
        }
Exemplo n.º 2
0
        internal OutputColumnDescriptor SetOutputColumnName(IdentifierOrValueExpression columnName)
        {
            if (columnName != null)
            {
                this.OutputColumnName = columnName.Value;
            }

            return(this);
        }
Exemplo n.º 3
0
 public override void ExplicitVisit(IdentifierOrValueExpression node)
 {
     // column from constant
     if (hasSetVariable)
     {
         outputSet.Clear();
     }
     else
     {
         throw new NotSupportedException(node.AsText());
         //outputSet.resultFragments.Add(node); // IdentifierOrValueExpression
     }
 }
        private BooleanIsNullExpression GetIsNotNull()
        {
            var isNull = new BooleanIsNullExpression();

            isNull.IsNot = true;
            var query = (isNull.Expression = new ScalarSubquery()) as ScalarSubquery;
            var spec  = (query.QueryExpression = new QuerySpecification()) as QuerySpecification;

            spec.SelectElements.Add(new SelectStarExpression());
            var fromTable = new QueryDerivedTable();

            spec.FromClause = new FromClause();
            spec.FromClause.TableReferences.Add(fromTable);
            var subQuerySpec = new QuerySpecification();
            var version      = new GlobalVariableExpression();

            version.Name = "@@version";

            var columnName = new IdentifierOrValueExpression();

            //var v = (columnName.ValueExpression = new StringLiteral()) as StringLiteral;
            //v.Value = "v";
            columnName.Identifier       = new Identifier();
            columnName.Identifier.Value = "v";


            subQuerySpec.SelectElements.Add(new SelectScalarExpression {
                Expression = version, ColumnName = columnName
            });
            fromTable.QueryExpression = subQuerySpec;
            fromTable.Alias           = new Identifier {
                Value = "edition"
            };

            spec.WhereClause = new WhereClause();
            var likePredicate = (spec.WhereClause.SearchCondition = new LikePredicate()) as LikePredicate;
            var col           = (likePredicate.FirstExpression = new ColumnReferenceExpression()) as ColumnReferenceExpression;

            col.ColumnType          = ColumnType.Regular;
            col.MultiPartIdentifier = new MultiPartIdentifier();
            col.MultiPartIdentifier.Identifiers.Add(new Identifier {
                Value = "v"
            });
            var ver = (likePredicate.SecondExpression = new StringLiteral()) as StringLiteral;

            ver.Value = "%Enterprise%";

            return(isNull);
        }
Exemplo n.º 5
0
 private WIdentifierOrValueExpression ParseIdentifierOrValueExpression(IdentifierOrValueExpression value)
 {
     if (value == null)
         return null;
     if (GraphViewKeywords._keywords.Contains(value.Identifier.Value))
     {
         var token = _tokens[value.FirstTokenIndex];
         throw new SyntaxErrorException(token.Line, value.Identifier.Value,
             "System restricted Name cannot be used");
     }
     return new WIdentifierOrValueExpression
     {
         FirstTokenIndex = value.FirstTokenIndex,
         LastTokenIndex = value.LastTokenIndex,
         Identifier = value.Identifier,
         ValueExpression = ParseScalarExpression(value.ValueExpression) as WValueExpression
     };
 }
Exemplo n.º 6
0
 public override void Visit(IdentifierOrValueExpression node) { this.action(node); }
 public override void ExplicitVisit(IdentifierOrValueExpression fragment)
 {
     _fragments.Add(fragment);
 }
Exemplo n.º 8
0
        private void ProcessViewStatementBody(TSqlStatement sqlStatement)
        {
            ViewStatementBody aViewStatementBody = (ViewStatementBody)sqlStatement;

            AddLogText("Columns:");
            foreach (Identifier aColumnIdentifier in aViewStatementBody.Columns)
            {
                AddLogText(string.Format("Column:{0}", aColumnIdentifier.Value));
                aColumnInfoList.ColumnList.Add(new ColumnInfo {
                    Alias = aColumnIdentifier.Value
                });
            }

            AddLogText("");
            AddLogText("QueryExpression SelectElements:");
            SelectStatement aSelectStatement = aViewStatementBody.SelectStatement;
            QueryExpression aQueryExpression = aSelectStatement.QueryExpression;

            if (aQueryExpression.GetType() == typeof(QuerySpecification))
            {
                QuerySpecification aQuerySpecification = (QuerySpecification)aQueryExpression;
                int aSelectElementID = 0;
                foreach (SelectElement aSelectElement in aQuerySpecification.SelectElements)
                {
                    if (aSelectElement.GetType() == typeof(SelectScalarExpression))
                    {
                        SelectScalarExpression aSelectScalarExpression = (SelectScalarExpression)aSelectElement;

                        string identStr = string.Empty;
                        IdentifierOrValueExpression aIdentifierOrValueExpression =
                            aSelectScalarExpression.ColumnName;
                        if (aIdentifierOrValueExpression != null)
                        {
                            if (aIdentifierOrValueExpression.ValueExpression == null)
                            {
                                AddLogText(string.Format("Identifier={0}",
                                                         aIdentifierOrValueExpression.Identifier.Value));
                                identStr = aIdentifierOrValueExpression.Identifier.Value;
                            }
                            else
                            {
                                AddLogText("Expression");
                            }
                        }
                        aColumnInfoList.AddIfNeeded(aSelectElementID, identStr);

                        ScalarExpression aScalarExpression = aSelectScalarExpression.Expression;
                        PrintSelectScalarExperssionRecurse(aSelectElementID, aScalarExpression);
                    }
                    else
                    {
                        aColumnInfoList.AddIfNeeded(aSelectElementID,
                                                    "Error, something else than SelectScalarExpression found");
                        AddLogText("We only support SelectScalarExpression.");
                    }
                    aSelectElementID = aSelectElementID + 1;
                    AddLogText("");
                }
                AddLogText("");
                AddLogText("Table References:");
                FromClause aFromClause = aQuerySpecification.FromClause;
                foreach (TableReference aTableReference in aFromClause.TableReferences)
                {
                    PrintTableReferenceRecurse(aTableReference);
                }
            }
            aColumnInfoList.FillEmptyAlias();
        }//function