Exemplo n.º 1
0
        public void AddForeignKey(object sender, ExecutedRoutedEventArgs e)
        {
            var menuInfo = ValidateMenuInfo(sender);

            if (menuInfo == null)
            {
                return;
            }
            try
            {
                using (var repository = DataConnectionHelper.CreateRepository(menuInfo.DatabaseInfo))
                {
                    var fkDlg = new ForeignKeyDialog(menuInfo.Name);
                    fkDlg.AllColumns     = repository.GetAllColumns().ToList();
                    fkDlg.AllPrimaryKeys = repository.GetAllPrimaryKeys();
                    if (fkDlg.ShowModal() != true)
                    {
                        return;
                    }
                    var generator = DataConnectionHelper.CreateGenerator(repository, menuInfo.DatabaseInfo.DatabaseType);
                    generator.GenerateForeignKey(fkDlg.NewKey);
                    OpenSqlEditorToolWindow(menuInfo, generator.GeneratedScript);
                    DataConnectionHelper.LogUsage("TableKeyAdd");
                }
            }
            catch (Exception ex)
            {
                DataConnectionHelper.SendError(ex, menuInfo.DatabaseInfo.DatabaseType, false);
            }
        }
Exemplo n.º 2
0
        private void OnForeignKeys(object sender, EventArgs e)
        {
            ForeignKeyDialog dlg = new ForeignKeyDialog(tableNode);

            dlg.ShowDialog();
        }