Пример #1
0
 public ColumnPairEntity(ColumnEntity parentColumn, ColumnEntity childColumn)
 {
     this.parentColumn = parentColumn;
     this.childColumn  = childColumn;
     //this.parentTableName = parentTable.GetName();
     //this.childTableName = childTable.GetName();
 }
        public List <JoinControl> DeleteColumnAndAllDependencies(TableEntity te, ColumnEntity ce)
        {
            List <JoinControl> deleted = new List <JoinControl>();

            // delete join pairs / controls

            List <JoinControl> joinsTemp = new List <JoinControl>(joins);

            foreach (JoinControl jc in joinsTemp)
            {
                List <ColumnPairEntity> joinPairsTemp = new List <ColumnPairEntity>(jc.GetJoinEntity().GetJoinPairs());

                foreach (ColumnPairEntity cpe in joinPairsTemp)
                {
                    if (cpe.GetParentColumn() == ce || cpe.GetChildColumn() == ce)
                    {
                        jc.GetJoinEntity().GetJoinPairs().Remove(cpe);
                    }
                }

                if (jc.GetJoinEntity().GetJoinPairs().Count == 0)
                {
                    joins.Remove(jc);
                    deleted.Add(jc);
                }
            }


            // delete join entities

            List <JoinEntity> joinEntitiesTemp = new List <JoinEntity>(joinEntities);

            foreach (JoinEntity je in joinEntitiesTemp)
            {
                foreach (JoinControl jc in deleted)
                {
                    if (je == jc.GetJoinEntity())
                    {
                        joinEntities.Remove(je);
                    }
                }
            }

            // delete columns

            List <ColumnEntity> columnEntitiesTemp = new List <ColumnEntity>(te.GetColumns());

            foreach (ColumnEntity column in columnEntitiesTemp)
            {
                if (ce == column)
                {
                    te.GetColumns().Remove(column);
                }
            }

            return(deleted);
        }
Пример #3
0
        public void RemoveColumnEntity(ColumnEntity ce)
        {
            if (tableColumns != null)
            {
                List <ColumnEntity> tableColumnsTemp = new List <ColumnEntity>(tableColumns);

                foreach (ColumnEntity ColumnEntity in tableColumnsTemp)
                {
                    tableColumns.Remove(ColumnEntity);
                }
            }
        }
Пример #4
0
 public void RemoveColumn(String columnName)
 {
     if (tableColumns != null)
     {
         foreach (ColumnEntity ColumnEntity in tableColumns)
         {
             if (ColumnEntity.GetColumnName() == columnName.ToUpper().Trim())
             {
                 tableColumns.Remove(ColumnEntity);
             }
         }
     }
 }
Пример #5
0
        public bool AddColumn(String columnName, String columnType, int columnLength, bool columnIsUnique)
        {
            ColumnEntity exists = null;

            foreach (ColumnEntity ce in tableColumns)
            {
                if (ce.GetColumnName() == columnName.ToUpper().Trim())
                {
                    exists = ce;
                }
            }

            if (exists == null)
            {
                ColumnEntity ce = new ColumnEntity(columnName.ToUpper().Trim(), columnType.ToUpper().Trim(), columnLength, columnIsUnique);
                tableColumns.Add(ce);
                return(true); // ColumnEntity was added
            }
            else
            {
                return(false); // ColumnEntity wasnt added because it already exists
            }
        }
Пример #6
0
 public void SetChildColumn(ColumnEntity childColumn)
 {
     this.childColumn = childColumn;
 }
Пример #7
0
 public void SetParentColumn(ColumnEntity parentColumn)
 {
     this.parentColumn = parentColumn;
 }