Beispiel #1
0
        private void ValidateFKbutton_Click(object sender, EventArgs e)
        {
            string schemaname = "";

            ds = DMEEditor.GetDataSource(dataSourceIDComboBox.Text);
            IRDBSource rdb = null;

            if (ds.Category == DatasourceCategory.RDBMS)
            {
                rdb        = (IRDBSource)SourceConnection;
                schemaname = rdb.GetSchemaName();
                EntityStructure.Relations = rdb.GetEntityforeignkeys(EntityName.ToUpper(), schemaname);
                dataHierarchyBindingSource.ResetBindings(false);
            }
        }
        private EntityStructure SetupEntityInView(IDMDataView v, List <EntityStructure> Rootnamespacelist, string childtable, string parenttable, string childcolumn, string parentcolumn, int pid, string Datasourcename)
        {
            EntityStructure a;
            int             pkid       = NextHearId();
            IDataSource     ds         = DMEEditor.GetDataSource(Datasourcename);
            string          schemaname = "";

            if (ds.Category == DatasourceCategory.RDBMS)
            {
                IRDBSource rdb = (IRDBSource)ds;
                schemaname = rdb.GetSchemaName();
            }

            if (!Rootnamespacelist.Where(f => f.ParentId == pid && f.EntityName.Equals(childtable, StringComparison.OrdinalIgnoreCase)).Any())//f => f.Id == childtable &&
            {
                //a = new EntityStructure() { Id = pkid, ParentId = pid, EntityName = childtable.ToUpper(), ViewID = v.ViewID };
                //a.DataSourceID = v.Entities.Where(x => x.Id == pid).FirstOrDefault().DataSourceID;
                //a.DatasourceEntityName = childtable;
                //a.Relations = ds.GetEntityforeignkeys(childtable.ToUpper(), schemaname);

                a          = (EntityStructure)ds.GetEntityStructure(childtable, true).Clone();
                a.ParentId = pid;
                a.Id       = NextHearId();
                Rootnamespacelist.Add(a);
            }
            else
            {
                a = Rootnamespacelist.Where(f => f.ParentId == pid && f.EntityName.Equals(childtable, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); //f.Id == childtable &&
                //  a.DataSourceID = DatasourceName;
                a.DatasourceEntityName = childtable;
                a.Relations.Add(new RelationShipKeys {
                    EntityColumnID = childcolumn.ToUpper(), ParentEntityColumnID = parentcolumn.ToUpper(), ParentEntityID = parenttable.ToUpper()
                });
            }
            return(a);
        }