public static TableColumn createTableColumn(Table table, TResultColumn column)
 {
     if (column.AliasClause != null && column.AliasClause.AliasName != null)
     {
         TableColumn columnModel = new TableColumn(table, column.AliasClause.AliasName);
         ModelBindingManager.bindModel(column, columnModel);
         return(columnModel);
     }
     return(null);
 }
Exemple #2
0
 private int getIndexOf(TResultColumnList resultColumnList, TResultColumn resultColumnObject)
 {
     for (int i = 0; i < resultColumnList.size(); i++)
     {
         if (resultColumnList.getResultColumn(i) == resultColumnObject)
         {
             return(i);
         }
     }
     return(-1);
 }
        public static ResultColumn createResultColumn(ResultSet resultSet, TResultColumn resultColumn)
        {
            if (ModelBindingManager.getModel(resultColumn) is ResultColumn)
            {
                return((ResultColumn)ModelBindingManager.getModel(resultColumn));
            }
            ResultColumn column = new ResultColumn(resultSet, resultColumn);

            ModelBindingManager.bindModel(resultColumn, column);
            return(column);
        }
        public static ResultColumn createResultColumn(QueryTable queryTableModel, TResultColumn resultColumn)
        {
            if (ModelBindingManager.getModel(resultColumn) is ResultColumn)
            {
                return((ResultColumn)ModelBindingManager.getModel(resultColumn));
            }
            ResultColumn column = new ResultColumn(queryTableModel, resultColumn);

            ModelBindingManager.bindModel(resultColumn, column);
            return(column);
        }
Exemple #5
0
        public ResultColumn(ResultSet resultSet, TResultColumn resultColumnObject)
        {
            if (resultColumnObject == null || resultSet == null)
            {
                throw new System.ArgumentException("ResultColumn arguments can't be null.");
            }

            id = ++TableColumn.TABLE_COLUMN_ID;

            this.resultSet = resultSet;
            resultSet.addColumn(this);

            this.columnObject = resultColumnObject;

            if (resultColumnObject.AliasClause != null)
            {
                this.alias = resultColumnObject.AliasClause.ToString();
                TSourceToken aliasStartToken = resultColumnObject.AliasClause.startToken;
                TSourceToken aliasEndToken   = resultColumnObject.AliasClause.endToken;
                this.aliasStartPosition = new Tuple <long, long>(aliasStartToken.lineNo, aliasStartToken.columnNo);
                this.aliasEndPosition   = new Tuple <long, long>(aliasEndToken.lineNo, aliasEndToken.columnNo + aliasEndToken.astext.Length);

                this.name = this.alias;
            }
            else
            {
                if (resultColumnObject.Expr.ExpressionType == EExpressionType.simple_constant_t)
                {
                    this.name = resultColumnObject.ToString();
                }
                else if (resultColumnObject.Expr.ExpressionType == EExpressionType.sqlserver_proprietary_column_alias_t)
                {
                    TSourceToken startToken1 = resultColumnObject.Expr
                                               .LeftOperand
                                               .startToken;
                    TSourceToken endToken1 = resultColumnObject.Expr
                                             .LeftOperand
                                             .endToken;
                    this.alias = resultColumnObject.Expr
                                 .LeftOperand
                                 .ToString();
                    this.aliasStartPosition = new Tuple <long, long>(startToken1.lineNo,
                                                                     startToken1.columnNo);
                    this.aliasEndPosition = new Tuple <long, long>(endToken1.lineNo,
                                                                   endToken1.columnNo + endToken1.astext.Length);

                    this.name = this.alias;
                }
                else if (resultColumnObject.Expr.ExpressionType == EExpressionType.function_t)
                {
                    this.name = resultColumnObject.Expr
                                .FunctionCall
                                .FunctionName
                                .ToString();
                }
                else if (resultColumnObject.ColumnNameOnly != null &&
                         !"".Equals(resultColumnObject.ColumnNameOnly))
                {
                    this.name = resultColumnObject.ColumnNameOnly;
                }
                else
                {
                    this.name = resultColumnObject.ToString();
                }
            }

            if (resultColumnObject.Expr.ExpressionType == EExpressionType.function_t)
            {
                this.fullName = resultColumnObject.Expr
                                .FunctionCall
                                .FunctionName
                                .ToString();
            }
            else
            {
                this.fullName = resultColumnObject.ToString();
            }

            TSourceToken startToken = resultColumnObject.startToken;
            TSourceToken endToken   = resultColumnObject.endToken;

            this.startPosition = new Tuple <long, long>(startToken.lineNo, startToken.columnNo);
            this.endPosition   = new Tuple <long, long>(endToken.lineNo, endToken.columnNo + endToken.astext.Length);
        }
        public static ResultColumn createSelectSetResultColumn(ResultSet resultSet, TResultColumn resultColumn)
        {
            SelectSetResultColumn column = new SelectSetResultColumn(resultSet, resultColumn);

            return(column);
        }