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);
 }
        public static ResultColumn createResultColumn(ResultSet resultSet, TObjectName 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 createSelectSetResultColumn(ResultSet resultSet, ResultColumn resultColumn)
        {
            if (ModelBindingManager.getModel(resultColumn) is ResultColumn)
            {
                return((ResultColumn)ModelBindingManager.getModel(resultColumn));
            }
            ResultColumn column = new SelectSetResultColumn(resultSet, resultColumn);

            ModelBindingManager.bindModel(resultColumn, column);
            return(column);
        }
        public static ResultColumn createStarResultColumn(SelectResultSet resultSet, Tuple <TResultColumn, TObjectName> starColumnPair)
        {
            if (ModelBindingManager.getModel(starColumnPair) is ResultColumn)
            {
                return((ResultColumn)ModelBindingManager.getModel(starColumnPair));
            }
            ResultColumn column = new ResultColumn(resultSet, starColumnPair);

            ModelBindingManager.bindModel(starColumnPair, column);
            return(column);
        }
        public static SelectSetResultSet createSelectSetResultSet(TSelectSqlStatement stmt)
        {
            if (ModelBindingManager.getModel(stmt) is SelectSetResultSet)
            {
                return((SelectSetResultSet)ModelBindingManager.getModel(stmt));
            }
            SelectSetResultSet resultSet = new SelectSetResultSet(stmt);

            ModelBindingManager.bindModel(stmt, resultSet);
            return(resultSet);
        }
        public static ResultSet createResultSet(TParseTreeNode gspObject)
        {
            if (ModelBindingManager.getModel(gspObject) is ResultSet)
            {
                return((ResultSet)ModelBindingManager.getModel(gspObject));
            }
            ResultSet resultSet = new ResultSet(gspObject);

            ModelBindingManager.bindModel(gspObject, resultSet);
            return(resultSet);
        }
        public static TableColumn createTableColumn(Table table, TObjectName column)
        {
            if (ModelBindingManager.getModel(new Tuple <Table, TObjectName>(table, column)) is TableColumn)
            {
                return((TableColumn)ModelBindingManager.getModel(new Tuple <Table, TObjectName>(table, column)));
            }
            TableColumn columnModel = new TableColumn(table, column);

            ModelBindingManager.bindModel(new Tuple <Table, TObjectName>(table, column), columnModel);
            return(columnModel);
        }
        public static SelectResultSet createResultSet(TSelectSqlStatement select)
        {
            if (ModelBindingManager.getModel(select.ResultColumnList) is ResultSet)
            {
                return((SelectResultSet)ModelBindingManager.getModel(select.ResultColumnList));
            }
            SelectResultSet resultSet = new SelectResultSet(select);

            ModelBindingManager.bindModel(select.ResultColumnList, resultSet);
            return(resultSet);
        }
        public static Table createTable(TTable table)
        {
            if (ModelBindingManager.getModel(table) is Table)
            {
                return((Table)ModelBindingManager.getModel(table));
            }
            Table tableModel = new Table(table);

            ModelBindingManager.bindModel(table, tableModel);
            return(tableModel);
        }
        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);
        }
        public static QueryTable createQueryTable(TTable table)
        {
            QueryTable tableModel = null;

            if (table.CTE != null)
            {
                if (ModelBindingManager.getModel(table.CTE) is QueryTable)
                {
                    return((QueryTable)ModelBindingManager.getModel(table.CTE));
                }

                tableModel = new QueryTable(table);

                ModelBindingManager.bindModel(table.CTE, tableModel);
            }
            else if (table.Subquery != null && table.Subquery.ResultColumnList != null)
            {
                if (ModelBindingManager.getModel(table.Subquery.ResultColumnList) is QueryTable)
                {
                    return((QueryTable)ModelBindingManager.getModel(table.Subquery.ResultColumnList));
                }

                tableModel = new QueryTable(table);
                ModelBindingManager.bindModel(table.Subquery.ResultColumnList, tableModel);
            }
            else
            {
                if (ModelBindingManager.getModel(table) is QueryTable)
                {
                    return((QueryTable)ModelBindingManager.getModel(table));
                }
                tableModel = new QueryTable(table);
                ModelBindingManager.bindModel(table, tableModel);
            }
            return(tableModel);
        }