Example #1
0
        public override void GetObjectList(List <AppObject> objs, AppObject appobj, ConnectionPack connpack)
        {
            ObjectPath objpath = appobj.GetObjectPath();
            var        tsrc    = appobj.TableSource;

            //IDatabaseSource conn = appobj.FindDatabaseConnection(connpack);
            if (tsrc == null)
            {
                return;
            }
            if (!tsrc.Connection.IsOpened)
            {
                return;
            }
            var ts = tsrc.InvokeLoadStructure(TableStructureMembers.Columns | TableStructureMembers.PrimaryKey | TableStructureMembers.ForeignKeys);

            foreach (var col in ts.Columns)
            {
                var cobj = new ColumnAppObject();
                cobj.Column = new ColumnStructure(col);
                cobj.FillFromTable(tsrc);
                cobj.FillRelatedConstraints(ts.Constraints);
                objs.Add(cobj);
            }
        }
Example #2
0
        public Column_TreeNode(ITableSource conn, ITableStructure table, IColumnStructure column, ITreeNode parent)
            : base(conn, parent, column.ColumnName)
        {
            m_column = column;
            m_table  = table;
            m_conn   = conn;

            m_ispk = m_table.GetKeyWithColumn <IPrimaryKey>(m_column) != null;
            m_isfk = m_table.GetKeyWithColumn <IForeignKey>(m_column) != null;
            StringBuilder res = new StringBuilder(m_column.ColumnName);

            res.Append(" (");
            if (m_ispk)
            {
                res.Append("PK, ");
            }
            if (m_isfk)
            {
                res.Append("FK, ");
            }
            if (m_conn.Database.Dialect != null)
            {
                res.Append(m_conn.Database.Dialect.GenericTypeToSpecific(m_column.DataType).ToString().ToLower());
            }
            else
            {
                res.Append(m_column.DataType.ToString().ToLower());
            }
            res.Append(", ");
            if (m_column.IsNullable)
            {
                res.Append("null");
            }
            else
            {
                res.Append("not null");
            }
            res.Append(")");
            m_title = res.ToString();

            var appobj = new ColumnAppObject();

            appobj.FillFromTable(conn);
            appobj.Column = new ColumnStructure(column);
            appobj.FillRelatedConstraints(table.Constraints);
            SetAppObject(appobj);
        }