public IndexContextMenu(MenuCommandParameters menuCommandParameters, ExplorerControl parent)
 {
     var tcmd = new IndexMenuCommandsHandler(parent);
     CreateScriptAsCreateMenuItem(tcmd, menuCommandParameters);
     CreateScriptAsDropMenuItem(tcmd, menuCommandParameters);
     Items.Add(new Separator());
     CreateScriptAsStatisticsMenuItem(tcmd, menuCommandParameters);
     
 }
 public ColumnContextMenu(MenuCommandParameters menuCommandParameters, ExplorerControl parent)
 {
     var tcmd = new ColumnMenuCommandsHandler(parent);
     CreateScriptAsCreateMenuItem(tcmd, menuCommandParameters);
     CreateScriptAsDropMenuItem(tcmd, menuCommandParameters);
     CreateScriptAsAlterMenuItem(tcmd, menuCommandParameters);
     Items.Add(new Separator());
     CreateDescriptionMenuItem(tcmd, menuCommandParameters);
 }
         public SubscriptionsContextMenu(MenuCommandParameters subsMenuCommandParameters, ExplorerControl parent)
        {
            var dcmd = new SubscriptionsMenuCommandsHandler(parent);

            if (subsMenuCommandParameters.MenuItemType == MenuCommandParameters.MenuType.Manage)

            {
                var newSubsCommandBinding = new CommandBinding(SubscriptionsMenuCommands.SubscriptionCommand,
                                            dcmd.NewSubscription);

                var newSubsMenuItem = new MenuItem
                {
                    Header = "Manage Subscription...",
                    Icon = ImageHelper.GetImageFromResource("../resources/subs.png"),
                    Command = SubscriptionsMenuCommands.SubscriptionCommand,
                    CommandParameter = subsMenuCommandParameters,
                };
                newSubsMenuItem.CommandBindings.Add(newSubsCommandBinding);
                Items.Add(newSubsMenuItem);


                var dropSubsCommandBinding = new CommandBinding(SubscriptionsMenuCommands.SubscriptionCommand,
                            dcmd.DropSubscription);

                var dropSubsMenuItem = new MenuItem
                {
                    Header = "Drop Subscription...",
                    Icon = ImageHelper.GetImageFromResource("../resources/subs.png"),
                    Command = SubscriptionsMenuCommands.SubscriptionCommand,
                    CommandParameter = subsMenuCommandParameters,
                };
                dropSubsMenuItem.CommandBindings.Add(dropSubsCommandBinding);
                Items.Add(dropSubsMenuItem);            
            }
            else
            {
                var newSubsCommandBinding = new CommandBinding(SubscriptionsMenuCommands.SubscriptionCommand,
                                            dcmd.NewSubscription);

                var newSubsMenuItem = new MenuItem
                {
                    Header = "New Subscription...",
                    Icon = ImageHelper.GetImageFromResource("../resources/subs.png"),
                    Command = SubscriptionsMenuCommands.SubscriptionCommand,
                    CommandParameter = subsMenuCommandParameters,
                };
                newSubsMenuItem.CommandBindings.Add(newSubsCommandBinding);
                Items.Add(newSubsMenuItem);
            }
        }
Example #4
0
        private async void ExecuteSqlScriptInEditor()
        {
            try
            {
                StartQuerying();
                using (var repository = Helpers.RepositoryHelper.CreateRepository(DatabaseInfo))
                {
                    var sql           = GetSqlFromSqlEditorTextBox();
                    var schemaChanged = false;
                    if (sql.Length == 0)
                    {
                        return;
                    }

                    var sbSql = new StringBuilder(sql);
                    sbSql = sbSql.Replace("\r", " \r");
                    sbSql = sbSql.Replace("GO  \r", "GO\r");
                    sql   = sbSql.Replace("GO \r", "GO\r").ToString();

                    var sw = new Stopwatch();
                    sw.Start();

                    var dataset = await Task.Run(()
                                                 // ReSharper disable once AccessToDisposedClosure
                                                 => repository.ExecuteSql(sql, out schemaChanged, _ignoreDdlErrors));

                    sw.Stop();
                    FormatTime(sw);
                    if (dataset == null)
                    {
                        return;
                    }
                    ParseDataSetResultsToResultsBox(dataset);
                    if (!schemaChanged)
                    {
                        return;
                    }
                    ExplorerControl?.RefreshTables(DatabaseInfo);
                }
            }
            catch (Exception sqlException)
            {
                ParseSqlErrorToResultsBox(
                    RepositoryHelper.CreateEngineHelper(DatabaseInfo.DatabaseType).FormatError(sqlException));
            }
            finally
            {
                StopQuerying();
            }
        }
Example #5
0
 private void ExecuteSqlScriptInEditor()
 {
     try
     {
         using (var repository = DataConnectionHelper.CreateRepository(DatabaseInfo))
         {
             var  sql = GetSqlFromSqlEditorTextBox();
             bool schemaChanged;
             if (sql.Length == 0)
             {
                 return;
             }
             var sbSql = new StringBuilder(sql);
             sbSql = sbSql.Replace("\r", " \r");
             sbSql = sbSql.Replace("GO  \r", "GO\r");
             sql   = sbSql.Replace("GO \r", "GO\r").ToString();
             var sw = new Stopwatch();
             sw.Start();
             var dataset = repository.ExecuteSql(sql, out schemaChanged, _ignoreDdlErrors);
             sw.Stop();
             FormatTime(sw);
             if (dataset == null)
             {
                 return;
             }
             ParseDataSetResultsToResultsBox(dataset);
             if (!schemaChanged)
             {
                 return;
             }
             if (ExplorerControl != null)
             {
                 ExplorerControl.RefreshTables(DatabaseInfo);
             }
         }
     }
     catch (Exception sqlException)
     {
         ParseSqlErrorToResultsBox(DataConnectionHelper.CreateEngineHelper(DatabaseInfo.DatabaseType).FormatError(sqlException));
     }
 }
 public TableContextMenu(MenuCommandParameters menuCommandParameters, ExplorerControl parent)
 {
     var tcmd = new TableMenuCommandsHandler(parent);
     CreateEditDataMenuItem(tcmd, menuCommandParameters);
     CreateViewReportMenuItem(tcmd, menuCommandParameters);
     Items.Add(new Separator());
     CreateScriptAsCreateMenuItem(tcmd, menuCommandParameters);
     CreateScriptAsDropMenuItem(tcmd, menuCommandParameters);
     CreateScriptAsDropAndCreateMenuItem(tcmd, menuCommandParameters);
     Items.Add(new Separator());
     CreateScriptAsSelectMenuItem(tcmd, menuCommandParameters);
     CreateScriptAsInsertMenuItem(tcmd, menuCommandParameters);
     CreateScriptAsUpdateMenuItem(tcmd, menuCommandParameters);
     CreateScriptAsDeleteMenuItem(tcmd, menuCommandParameters);
     CreateScriptAsDataMenuItem(tcmd, menuCommandParameters);
     Items.Add(new Separator());
     ImportDataMenuItem(tcmd, menuCommandParameters);
     Items.Add(new Separator());
     DescriptionMenuItem(tcmd, menuCommandParameters);
     Items.Add(new Separator());
     RenameMenuItem(tcmd, menuCommandParameters);
 }
 public SubscriptionsMenuCommandsHandler(ExplorerControl parent)
 {
     _parent = parent;
 }
 public BaseCommandHandler(ExplorerControl parent)
 {
     _parent = parent;
 }
Example #9
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (!_loaded)
            {
                DataConnectionHelper.Monitor = EQATEC.Analytics.Monitor.AnalyticsMonitorFactory.CreateMonitor("C244D8923C7C4235A1A24AB1127BD521");
                DataConnectionHelper.Monitor.Start();

                ExtractDll("QuickGraph.dll");
                ExtractDll("QuickGraph.Data.dll");
                
                if (DataConnectionHelper.Argument != null)
                {
                    string filePath = DataConnectionHelper.Argument.ToLowerInvariant();
                    if (System.IO.File.Exists(filePath))
                    {
                        var connStr = string.Format("Data Source={0};Max Database Size=4091", filePath);
                        var databaseList = DataConnectionHelper.GetDataConnections();
                        var item = databaseList.Where(d => d.Value.StartsWith(connStr)).FirstOrDefault();
                        if (item.Value == null)
                        {
                            try
                            {
                                TrySave(connStr);
                            }
                            catch (Exception ex)
                            {
                                string error = DataConnectionHelper.ShowErrors(ex);
                                if (error.Contains("Minor Err.: 25028"))
                                {
                                    PasswordDialog pwd = new PasswordDialog();
                                    pwd.ShowDialog();
                                    if (pwd.DialogResult.HasValue && pwd.DialogResult.Value == true && !string.IsNullOrWhiteSpace(pwd.Password))
                                    {   
                                        connStr = connStr + ";Password="******"SQL Server Compact Toolbox for runtime " + RepoHelper.apiVer;
                _explorerControl = new ExplorerControl(fabTab);
                MainGrid.Children.Add(_explorerControl);
            }
            _loaded = true;
        }
 public IndexMenuCommandsHandler(ExplorerControl parent)
 {
     _parentWindow = parent;
 }
        public DatabasesContextMenu(DatabasesMenuCommandParameters databaseMenuCommandParameters, ExplorerControl parent)
        {
            var dcmd = new DatabaseMenuCommandsHandler(parent);

            var toolTip1 = new ToolTip();

            bool runtimeIsInstalled = DataConnectionHelper.IsRuntimeInstalled();

            if (runtimeIsInstalled)
            {
                toolTip1.Content = string.Format("Install SQL Server Compact {0} desktop runtime to enable this feature", RepoHelper.apiVer);
            }
            else
            {
                toolTip1.Content = string.Format("Add SQL Server Compact {0} Connection", RepoHelper.apiVer);
            }
            var addCeDatabaseCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                        dcmd.AddCeDatabase);

            var addCeDatabaseMenuItem = new MenuItem
            {
                Header = string.Format("Add SQL Server Compact {0} Connection...", RepoHelper.apiVer),
                Icon = ImageHelper.GetImageFromResource("../resources/AddTableHS.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
				ToolTip = toolTip1,
                CommandParameter = databaseMenuCommandParameters,
            };
            addCeDatabaseMenuItem.CommandBindings.Add(addCeDatabaseCommandBinding);
			addCeDatabaseMenuItem.IsEnabled = runtimeIsInstalled;
            Items.Add(addCeDatabaseMenuItem);

            Items.Add(new Separator());

            var scriptGraphCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                        dcmd.GenerateServerDgmlFiles);

            var toolTip = new ToolTip();
            toolTip.Content = "Generate a SQL Server Compact compatible database script from SQL Server 2005/2008";

            var scriptDatabaseGraphMenuItem = new MenuItem
            {
                Header = "Create SQL Server Database Graph (DGML)...",
                Icon = ImageHelper.GetImageFromResource("../resources/RelationshipsHS.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };
            scriptDatabaseGraphMenuItem.CommandBindings.Add(scriptGraphCommandBinding);
            Items.Add(scriptDatabaseGraphMenuItem);
            Items.Add(new Separator());

            var scriptDatabaseCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                dcmd.ScriptServerDatabase);

            var scriptDatabaseSchemaMenuItem = new MenuItem
                                             {
                                                 Header = "Script SQL Server Database Schema...",
                                                 Icon = ImageHelper.GetImageFromResource("../resources/database.png"),
                                                 ToolTip = toolTip,
                                                 Command = DatabaseMenuCommands.DatabaseCommand,
                                                 CommandParameter = databaseMenuCommandParameters,
                                                 Tag = SqlCeScripting.Scope.Schema
                                             };
            scriptDatabaseSchemaMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            Items.Add(scriptDatabaseSchemaMenuItem);

            var scriptDatabaseDataMenuItem = new MenuItem
            {
                Header = "Script SQL Server Database Data...",
                Icon = ImageHelper.GetImageFromResource("../resources/database.png"),
                ToolTip = toolTip,
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.DataOnly
            };
            scriptDatabaseDataMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            Items.Add(scriptDatabaseDataMenuItem);

            var scriptDatabaseSchemaDataMenuItem = new MenuItem
                                                {
                                                    Header = "Script SQL Server Database Schema and Data...",
                                                    Icon = ImageHelper.GetImageFromResource("../resources/database.png"),
                                                    ToolTip = toolTip,
                                                    Command = DatabaseMenuCommands.DatabaseCommand,
                                                    CommandParameter = databaseMenuCommandParameters,
                                                    Tag = SqlCeScripting.Scope.SchemaData 
                                                };
            scriptDatabaseSchemaDataMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            Items.Add(scriptDatabaseSchemaDataMenuItem);

            var scriptDatabaseSchemaDataBLOBMenuItem = new MenuItem
            {
                Header = "Script SQL Server Database Schema and Data with BLOBs...",
                ToolTip = toolTip,
                Icon = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.SchemaDataBlobs 
            };
            scriptDatabaseSchemaDataBLOBMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            Items.Add(scriptDatabaseSchemaDataBLOBMenuItem);

            Items.Add(new Separator());

            var exportServerCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                dcmd.ExportServerDatabaseTo40);            
            var exportServerMenuItem = new MenuItem
            {
                Header = string.Format("Export SQL Server to SQL Server Compact {0} ...", RepoHelper.apiVer),
                Icon = ImageHelper.GetImageFromResource("../resources/data_out_small.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters
            };
            exportServerMenuItem.CommandBindings.Add(exportServerCommandBinding);
            exportServerMenuItem.IsEnabled = runtimeIsInstalled;
            Items.Add(exportServerMenuItem);

            Items.Add(new Separator());
            var detectDatabaseCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                            dcmd.CheckCeVersion);

            var versionDetectMenuItem = new MenuItem
            {
                Header = "Detect SQL Server Compact file version...",
                Icon = ImageHelper.GetImageFromResource("../resources/ZoomHS.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };
            versionDetectMenuItem.CommandBindings.Add(detectDatabaseCommandBinding);
            Items.Add(versionDetectMenuItem);

            //if (RepoHelper.apiVer == "4.0" && 1 == 0)
            //{
            //    Items.Add(new Separator());
            //    var installDDEX4CommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
            //                    dcmd.InstallDDEX4);

            //    var installDDEX4MenuItem = new MenuItem
            //    {
            //        Header = "Enable VS Express 2013 to use SQL Server Compact 4.0 with Entity Framework 6",
            //        Icon = ImageHelper.GetImageFromResource("../resources/RelationshipsHS.png"),
            //        Command = DatabaseMenuCommands.DatabaseCommand,
            //        CommandParameter = databaseMenuCommandParameters,
            //    };
            //    installDDEX4MenuItem.CommandBindings.Add(installDDEX4CommandBinding);
            //    Items.Add(installDDEX4MenuItem);
            //}
        }
 public ColumnMenuCommandsHandler(ExplorerControl parent)
 {
     _parentWindow = parent;
     _handler = new BaseCommandHandler(parent);
 }
 public TableMenuCommandsHandler(ExplorerControl parent) : base(parent)
 {
 }
        public DatabaseContextMenu(DatabaseMenuCommandParameters databaseMenuCommandParameters, ExplorerControl parent)
        {
            var dcmd = new DatabaseMenuCommandsHandler(parent);

            var showSqlEditorCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                dcmd.SpawnSqlEditorWindow);
            var showSqlEditorMenuItem = new MenuItem
            {
                Header = "Open SQL Editor",
                Icon = ImageHelper.GetImageFromResource("../resources/sqlEditor.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters
            };
            showSqlEditorMenuItem.CommandBindings.Add(showSqlEditorCommandBinding);
            Items.Add(showSqlEditorMenuItem);

            var createTableCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                        dcmd.BuildTable);
            var createTableMenuItem = new MenuItem
            {
                Header = "Build Table (alpha)...",
                Icon = ImageHelper.GetImageFromResource("../resources/sqlEditor.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters
            };
            createTableMenuItem.CommandBindings.Add(createTableCommandBinding);
            Items.Add(createTableMenuItem);

            Items.Add(new Separator());

            var scriptMenuItem = new MenuItem
            {
                Header = "Script",
                Icon = ImageHelper.GetImageFromResource("../resources/database.png")
            };

            var scriptDatabaseCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                                dcmd.ScriptDatabase);
            var scriptDatabaseSchemaMenuItem = new MenuItem
            {
                Header = "Script Database Schema...",
                Icon = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.Schema
            };
            scriptDatabaseSchemaMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            scriptMenuItem.Items.Add(scriptDatabaseSchemaMenuItem);

            var scriptDatabaseSchemaDataMenuItem = new MenuItem
            {
                Header = "Script Database Schema and Data...",
                Icon = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.SchemaData
            };
            scriptDatabaseSchemaDataMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            scriptMenuItem.Items.Add(scriptDatabaseSchemaDataMenuItem);

            var scriptAzureSchemaDataMenuItem = new MenuItem
            {
                Header = "Script Database Schema and Data for SQL Azure...",
                Icon = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.SchemaDataAzure
            };
            scriptAzureSchemaDataMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            scriptMenuItem.Items.Add(scriptAzureSchemaDataMenuItem);

            var scriptSqliteSchemaDataMenuItem = new MenuItem
            {
                Header = "Script Database Schema and Data for SQLite (beta)...",
                Icon = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.SchemaDataSQLite
            };
            scriptSqliteSchemaDataMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            scriptMenuItem.Items.Add(scriptSqliteSchemaDataMenuItem);

            var scriptDatabaseSchemaDataBLOBMenuItem = new MenuItem
            {
                Header = "Script Database Schema and Data with BLOBs...",
                Icon = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.SchemaDataBlobs
            };
            scriptDatabaseSchemaDataBLOBMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            scriptMenuItem.Items.Add(scriptDatabaseSchemaDataBLOBMenuItem);

            var scriptDatabaseDataMenuItem = new MenuItem
            {
                Header = "Script Database Data...",
                Icon = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.DataOnly
            };
            scriptDatabaseDataMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            scriptMenuItem.Items.Add(scriptDatabaseDataMenuItem);

            var scriptDatabaseDataForServerMenuItem = new MenuItem
            {
                Header = "Script Database Data for SQL Server...",
                Icon = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = SqlCeScripting.Scope.DataOnlyForSqlServer
            };
            scriptDatabaseDataForServerMenuItem.CommandBindings.Add(scriptDatabaseCommandBinding);
            scriptMenuItem.Items.Add(scriptDatabaseDataForServerMenuItem);

            Items.Add(scriptMenuItem);

            Items.Add(new Separator());

            var scriptDiffCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                            dcmd.GenerateDiffScript);

            var scriptDatabaseDiffMenuItem = new MenuItem
            {
                Header = "Script Database Diff...",
                Icon = ImageHelper.GetImageFromResource("../resources/database.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };
            scriptDatabaseDiffMenuItem.CommandBindings.Add(scriptDiffCommandBinding);
            scriptDatabaseDiffMenuItem.ToolTip = "Script all tables, columns and constraints in this database\r\nthat are missing/different in the target database.";
            Items.Add(scriptDatabaseDiffMenuItem);

            Items.Add(new Separator());

            var scriptGraphCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                    dcmd.GenerateCeDgmlFiles);

            var scriptDatabaseGraphMenuItem = new MenuItem
            {
                Header = "Create Database Graph (DGML)...",
                Icon = ImageHelper.GetImageFromResource("../resources/RelationshipsHS.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };
            scriptDatabaseGraphMenuItem.CommandBindings.Add(scriptGraphCommandBinding);
            Items.Add(scriptDatabaseGraphMenuItem);

            // Documentation menu item

            var docDbCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                        dcmd.GenerateDocFiles);
            var docDatabaseMenuItem = new MenuItem
            {
                Header = "Create Database Documentation...",
                Icon = ImageHelper.GetImageFromResource("../resources/RelationshipsHS.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
            };
            docDatabaseMenuItem.CommandBindings.Add(docDbCommandBinding);
            Items.Add(docDatabaseMenuItem);

            Items.Add(new Separator());

            var scriptDCCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                            dcmd.GenerateDataContext);

            // Desktop Data Context
            var scriptDCMenuItem = new MenuItem
            {
                Header = "Create LINQ to SQL DataContext class...",
                Icon = ImageHelper.GetImageFromResource("../resources/RelationshipsHS.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = true
            };
            scriptDCMenuItem.CommandBindings.Add(scriptDCCommandBinding);
            Items.Add(scriptDCMenuItem);

            //Windows Phone Data Context
            var scriptWPDCMenuItem = new MenuItem
            {
                Header = "Create Windows Phone DataContext class...",
                Icon = ImageHelper.GetImageFromResource("../resources/Phone.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                Tag = false
            };
            scriptWPDCMenuItem.CommandBindings.Add(scriptDCCommandBinding);            
#if V35
            scriptWPDCMenuItem.IsEnabled = true;
#else
            scriptWPDCMenuItem.IsEnabled = false;
#endif
            Items.Add(scriptWPDCMenuItem);
            Items.Add(new Separator());

            var maintenanceMenuItem = new MenuItem
            {
                Header = "Maintenance",
                Icon = ImageHelper.GetImageFromResource("../resources/SplitSubdocumentHS.png"),
            };

            var shrinkCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                    dcmd.ShrinkDatabase);
            var shrinkMenuItem = new MenuItem
            {
                Header = "Shrink",
                Icon = ImageHelper.GetImageFromResource("../resources/SplitSubdocumentHS.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip = "Shrink database by deleting free pages"
            };
            shrinkMenuItem.CommandBindings.Add(shrinkCommandBinding);
            maintenanceMenuItem.Items.Add(shrinkMenuItem);

            var compactCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                        dcmd.CompactDatabase);
            var compactMenuItem = new MenuItem
            {
                Header = "Compact",
                Icon = ImageHelper.GetImageFromResource("../resources/SplitSubdocumentHS.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip = "Perform full database compaction"
            };
            compactMenuItem.CommandBindings.Add(compactCommandBinding);
            maintenanceMenuItem.Items.Add(compactMenuItem);

            var verifyCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                dcmd.VerifyDatabase);
            var verifyMenuItem = new MenuItem
            {
                Header = "Verify",
                Icon = ImageHelper.GetImageFromResource("../resources/SplitSubdocumentHS.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip = "Verify the integrity of the database (enhanced)"
            };
            verifyMenuItem.CommandBindings.Add(verifyCommandBinding);
            maintenanceMenuItem.Items.Add(verifyMenuItem);

            var repairDeleteCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                            dcmd.RepairDatabaseDeleteCorruptedRows);
            var repairDeleteMenuItem = new MenuItem
            {
                Header = "Repair (delete corrupted rows)",
                Icon = ImageHelper.GetImageFromResource("../resources/SplitSubdocumentHS.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip = "Repairs a corrupted database"
            };
            repairDeleteMenuItem.CommandBindings.Add(repairDeleteCommandBinding);
            maintenanceMenuItem.Items.Add(repairDeleteMenuItem);

            var repairRecoverAllCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                            dcmd.RepairDatabaseRecoverAllOrFail);
            var repairRecoverAllMenuItem = new MenuItem
            {
                Header = "Repair (recover all or fail)",
                Icon = ImageHelper.GetImageFromResource("../resources/SplitSubdocumentHS.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip = "Repairs a corrupted database"
            };
            repairRecoverAllMenuItem.CommandBindings.Add(repairRecoverAllCommandBinding);
            maintenanceMenuItem.Items.Add(repairRecoverAllMenuItem);

            var repairRecoverPossibleCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                            dcmd.RepairDatabaseRecoverAllPossibleRows);
            var repairRecoverPossibleMenuItem = new MenuItem
            {
                Header = "Repair (recover all possible)",
                Icon = ImageHelper.GetImageFromResource("../resources/SplitSubdocumentHS.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters,
                ToolTip = "Repairs a corrupted database"
            };
            repairRecoverPossibleMenuItem.CommandBindings.Add(repairRecoverPossibleCommandBinding);
            maintenanceMenuItem.Items.Add(repairRecoverPossibleMenuItem);

            Items.Add(maintenanceMenuItem);

            Items.Add(new Separator());

            var addDescriptionCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                        dcmd.AddDescription);
            var addDescriptionMenuItem = new MenuItem
            {
                Header = "Edit description",
                Icon = ImageHelper.GetImageFromResource("../resources/propes.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters
            };
            addDescriptionMenuItem.CommandBindings.Add(addDescriptionCommandBinding);
            Items.Add(addDescriptionMenuItem);

            Items.Add(new Separator());

            var removeCeConnectionCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                    dcmd.RemoveCeDatabase);
            var removeCeConnectionMenuItem = new MenuItem
            {
                Header = "Remove Connection",
                Icon = ImageHelper.GetImageFromResource("../resources/delete.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = databaseMenuCommandParameters
            };
            removeCeConnectionMenuItem.CommandBindings.Add(removeCeConnectionCommandBinding);
            Items.Add(removeCeConnectionMenuItem);

        }