Beispiel #1
0
        void RemoveRelationNodeFromTable(string tableName, string nodeName)
        {
            TableNode tn = (TableNode)databaseNode.FindNode(tableName);

            if (tn != null)
            {
                RelationNode relNode = (RelationNode)tn.FindNode(nodeName, typeof(RelationNode));
                if (relNode != null)
                {
                    relNode.Remove();
                }
                //tn.Nodes. Remove(relNode);
            }
        }
Beispiel #2
0
        public bool MapIntermediateClass(TableNode tn)
        {
//			IntermediateClass ic = new IntermediateClass();
//			IntermediateClassNode icn = new IntermediateClassNode(ic, tn);

            IList tableNodes = new ArrayList();

            foreach (TableNode tnode in databaseNode.TableNodes)
            {
                if (tn.Text == tnode.Text)
                {
                    continue;
                }
                if (tnode.Table.MappingType == TableMappingType.MappedAsClass)
                {
                    tableNodes.Add(tnode);
                }
            }

            IntermediateClassWizardModel model = new IntermediateClassWizardModel(tn, tableNodes);

            IWizardController controller = ApplicationController.wizardControllerFactory.Create
                                               ("IntermediateClassWizController", "IntClassWiz", "Intermediate Class Wizard");

            //controller.FrameSize = new Size(544, 500);
            model[0].RelationDirection = RelationDirection.Bidirectional;
            model[1].RelationDirection = RelationDirection.Bidirectional;
            DialogResult r = controller.Run(model);

            if (r == DialogResult.OK)
            {
                DatabaseNode parent = (DatabaseNode)tn.Parent;
                // Nothing to remove, because we use the original table node
                //				tn.Remove();
                //				tn.Parent.Nodes.Add(icn);
                for (int i = 0; i < 2; i++)
                {
                    ColumnNode            columnNode   = (ColumnNode)tn.FindNode(model[i].ForeignKeyColumnName, typeof(ColumnNode));
                    FkRelation            fkr          = new FkRelation(columnNode.Text);
                    IntermediateClassInfo intermClInfo = model[i];
                    fkr.FieldName          = intermClInfo.OwnFieldName;
                    fkr.ForeignCodingStyle = intermClInfo.CodingStyle;
                    fkr.ForeignFieldName   = intermClInfo.ForeignFieldName;
                    fkr.ForeignIsComposite = false;
                    fkr.IsComposite        = false;
                    fkr.OwningTable        = tn.Text;
                    fkr.OwningType         = tn.Table.ClassName;
                    fkr.RelatedTable       = intermClInfo.Table;
                    fkr.RelatedType        = intermClInfo.Type;
                    fkr.RelationDirection  = intermClInfo.RelationDirection;
                    fkr.RelationName       = string.Empty;
                    //ForeignFkRelation ffkr = fkr.ForeignRelation;
                    RelationNode relationNode = new RelationNode(fkr, tn);
                    relationNode.RelatedTableNode = (TableNode)databaseNode.FindNode(intermClInfo.Table);
                    ForeignKeyWizModel fkwizModel = new ForeignKeyWizModel(relationNode, new ArrayList());

                    tn.DualKeyRelations[i] = intermClInfo.OwnFieldName;

                    MakeForeignKeyRelation(relationNode, columnNode, fkwizModel);
                }
                return(true);
            }
            return(false);
        }