diff --git a/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/CopyTableNameCommand.cs b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/CopyTableNameCommand.cs
new file mode 100644
index 0000000..ff20da0
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/CopyTableNameCommand.cs
@@ -0,0 +1,28 @@
+#region License
+
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+#endregion
+
+using System.Windows.Forms;
+using MiniSqlQuery.Core.Commands;
+
+namespace MiniSqlQuery.PlugIns.DatabaseInspector.Commands
+{
+ /// <summary>The copy table name command.</summary>
+ public class CopyTableNameCommand : CommandBase
+ {
+ /// <summary>Initializes a new instance of the <see cref="CopyTableNameCommand"/> class.</summary>
+ public CopyTableNameCommand()
+ : base("Copy table name")
+ {
+ }
+
+ /// <summary>Execute the command.</summary>
+ public override void Execute()
+ {
+ Clipboard.SetText(HostWindow.DatabaseInspector.RightClickedTableName);
+ }
+ }
+}
\ No newline at end of file
diff --git a/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateDeleteStatementCommand.cs b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateDeleteStatementCommand.cs
new file mode 100644
index 0000000..e0b7220
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateDeleteStatementCommand.cs
@@ -0,0 +1,38 @@
+#region License
+
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+#endregion
+
+using System.IO;
+using MiniSqlQuery.Core;
+using MiniSqlQuery.Core.DbModel;
+
+namespace MiniSqlQuery.PlugIns.DatabaseInspector.Commands
+{
+ /// <summary>The generate delete statement command.</summary>
+ public class GenerateDeleteStatementCommand : GenerateStatementCommandBase
+ {
+ /// <summary>Initializes a new instance of the <see cref="GenerateDeleteStatementCommand"/> class.</summary>
+ public GenerateDeleteStatementCommand()
+ : base("Generate Delete Statement")
+ {
+ }
+
+ /// <summary>Execute the command.</summary>
+ public override void Execute()
+ {
+ IQueryEditor editor = ActiveFormAsSqlQueryEditor;
+ string tableName = HostWindow.DatabaseInspector.RightClickedTableName;
+ DbModelInstance model = HostWindow.DatabaseInspector.DbSchema;
+
+ if (tableName != null && editor != null)
+ {
+ StringWriter sql = new StringWriter();
+ SqlWriter.WriteDelete(sql, GetTableOrViewByName(model, tableName));
+ editor.InsertText(sql.ToString());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateInsertStatementCommand.cs b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateInsertStatementCommand.cs
new file mode 100644
index 0000000..55f0802
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateInsertStatementCommand.cs
@@ -0,0 +1,38 @@
+#region License
+
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+#endregion
+
+using System.IO;
+using MiniSqlQuery.Core;
+using MiniSqlQuery.Core.DbModel;
+
+namespace MiniSqlQuery.PlugIns.DatabaseInspector.Commands
+{
+ /// <summary>The generate insert statement command.</summary>
+ internal class GenerateInsertStatementCommand : GenerateStatementCommandBase
+ {
+ /// <summary>Initializes a new instance of the <see cref="GenerateInsertStatementCommand"/> class.</summary>
+ public GenerateInsertStatementCommand()
+ : base("Generate Insert Statement")
+ {
+ }
+
+ /// <summary>Execute the command.</summary>
+ public override void Execute()
+ {
+ IQueryEditor editor = ActiveFormAsSqlQueryEditor;
+ string tableName = HostWindow.DatabaseInspector.RightClickedTableName;
+ DbModelInstance model = HostWindow.DatabaseInspector.DbSchema;
+
+ if (tableName != null && editor != null)
+ {
+ StringWriter sql = new StringWriter();
+ SqlWriter.WriteInsert(sql, GetTableOrViewByName(model, tableName));
+ editor.InsertText(sql.ToString());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateSelectCountStatementCommand.cs b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateSelectCountStatementCommand.cs
new file mode 100644
index 0000000..14efcf5
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateSelectCountStatementCommand.cs
@@ -0,0 +1,38 @@
+#region License
+
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+#endregion
+
+using System.IO;
+using MiniSqlQuery.Core;
+using MiniSqlQuery.Core.DbModel;
+
+namespace MiniSqlQuery.PlugIns.DatabaseInspector.Commands
+{
+ /// <summary>The generate select count statement command.</summary>
+ public class GenerateSelectCountStatementCommand : GenerateStatementCommandBase
+ {
+ /// <summary>Initializes a new instance of the <see cref="GenerateSelectCountStatementCommand"/> class.</summary>
+ public GenerateSelectCountStatementCommand()
+ : base("Generate Select COUNT(*) Statement")
+ {
+ }
+
+ /// <summary>Execute the command.</summary>
+ public override void Execute()
+ {
+ IQueryEditor editor = ActiveFormAsSqlQueryEditor;
+ string tableName = HostWindow.DatabaseInspector.RightClickedTableName;
+ DbModelInstance model = HostWindow.DatabaseInspector.DbSchema;
+
+ if (tableName != null && editor != null)
+ {
+ StringWriter sql = new StringWriter();
+ SqlWriter.WriteSelectCount(sql, GetTableOrViewByName(model, tableName));
+ editor.InsertText(sql.ToString());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateSelectStatementCommand.cs b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateSelectStatementCommand.cs
new file mode 100644
index 0000000..7265429
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateSelectStatementCommand.cs
@@ -0,0 +1,38 @@
+#region License
+
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+#endregion
+
+using System.IO;
+using MiniSqlQuery.Core;
+using MiniSqlQuery.Core.DbModel;
+
+namespace MiniSqlQuery.PlugIns.DatabaseInspector.Commands
+{
+ /// <summary>The generate select statement command.</summary>
+ public class GenerateSelectStatementCommand : GenerateStatementCommandBase
+ {
+ /// <summary>Initializes a new instance of the <see cref="GenerateSelectStatementCommand"/> class.</summary>
+ public GenerateSelectStatementCommand()
+ : base("Generate Select Statement")
+ {
+ }
+
+ /// <summary>Execute the command.</summary>
+ public override void Execute()
+ {
+ IQueryEditor editor = ActiveFormAsSqlQueryEditor;
+ string tableName = HostWindow.DatabaseInspector.RightClickedTableName;
+ DbModelInstance model = HostWindow.DatabaseInspector.DbSchema;
+
+ if (tableName != null && editor != null)
+ {
+ StringWriter sql = new StringWriter();
+ SqlWriter.WriteSelect(sql, GetTableOrViewByName(model, tableName));
+ editor.InsertText(sql.ToString());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateStatementCommandBase.cs b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateStatementCommandBase.cs
new file mode 100644
index 0000000..1464746
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateStatementCommandBase.cs
@@ -0,0 +1,70 @@
+#region License
+
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+#endregion
+
+using MiniSqlQuery.Core.Commands;
+using MiniSqlQuery.Core.DbModel;
+
+namespace MiniSqlQuery.PlugIns.DatabaseInspector.Commands
+{
+ /// <summary>The generate statement command base.</summary>
+ public abstract class GenerateStatementCommandBase : CommandBase
+ {
+ /// <summary>The _sql writer.</summary>
+ private ISqlWriter _sqlWriter;
+
+ /// <summary>Initializes a new instance of the <see cref="GenerateStatementCommandBase"/> class.</summary>
+ /// <param name="name">The name.</param>
+ public GenerateStatementCommandBase(string name)
+ : base(name)
+ {
+ }
+
+ /// <summary>Gets SqlWriter.</summary>
+ protected ISqlWriter SqlWriter
+ {
+ get
+ {
+ if (_sqlWriter == null)
+ {
+ _sqlWriter = Services.Resolve<ISqlWriter>();
+ }
+
+ return _sqlWriter;
+ }
+ }
+
+ /// <summary>The get table or view by name.</summary>
+ /// <param name="model">The model.</param>
+ /// <param name="tableName">The table name.</param>
+ /// <returns></returns>
+ protected DbModelTable GetTableOrViewByName(DbModelInstance model, string tableName)
+ {
+ DbModelTable tableOrView = model.FindTable(tableName);
+ if (tableOrView == null)
+ {
+ // check the views
+ tableOrView = model.FindView(tableName);
+ }
+
+ return tableOrView;
+ }
+
+ /// <summary>The trim trailing comma.</summary>
+ /// <param name="sql">The sql.</param>
+ /// <returns>The trim trailing comma.</returns>
+ protected string TrimTrailingComma(string sql)
+ {
+ if (sql != null && sql.TrimEnd().EndsWith(","))
+ {
+ string tmp = sql.TrimEnd();
+ return tmp.Substring(0, tmp.Length - 1);
+ }
+
+ return sql;
+ }
+ }
+}
\ No newline at end of file
diff --git a/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateUpdateStatementCommand.cs b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateUpdateStatementCommand.cs
new file mode 100644
index 0000000..2f90fe6
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/GenerateUpdateStatementCommand.cs
@@ -0,0 +1,38 @@
+#region License
+
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+#endregion
+
+using System.IO;
+using MiniSqlQuery.Core;
+using MiniSqlQuery.Core.DbModel;
+
+namespace MiniSqlQuery.PlugIns.DatabaseInspector.Commands
+{
+ /// <summary>The generate update statement command.</summary>
+ internal class GenerateUpdateStatementCommand : GenerateStatementCommandBase
+ {
+ /// <summary>Initializes a new instance of the <see cref="GenerateUpdateStatementCommand"/> class.</summary>
+ public GenerateUpdateStatementCommand()
+ : base("Generate Update Statement")
+ {
+ }
+
+ /// <summary>Execute the command.</summary>
+ public override void Execute()
+ {
+ IQueryEditor editor = ActiveFormAsSqlQueryEditor;
+ string tableName = HostWindow.DatabaseInspector.RightClickedTableName;
+ DbModelInstance model = HostWindow.DatabaseInspector.DbSchema;
+
+ if (tableName != null && editor != null)
+ {
+ StringWriter sql = new StringWriter();
+ SqlWriter.WriteUpdate(sql, GetTableOrViewByName(model, tableName));
+ editor.InsertText(sql.ToString());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/LocateFkReferenceColumnCommand.cs b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/LocateFkReferenceColumnCommand.cs
new file mode 100644
index 0000000..ec425e4
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/LocateFkReferenceColumnCommand.cs
@@ -0,0 +1,41 @@
+#region License
+
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+#endregion
+
+using MiniSqlQuery.Core.DbModel;
+
+namespace MiniSqlQuery.PlugIns.DatabaseInspector.Commands
+{
+ /// <summary>The locate fk reference column command.</summary>
+ public class LocateFkReferenceColumnCommand : GenerateStatementCommandBase
+ {
+ /// <summary>Initializes a new instance of the <see cref="LocateFkReferenceColumnCommand"/> class.</summary>
+ public LocateFkReferenceColumnCommand()
+ : base("Jump to FK column reference...")
+ {
+ }
+
+ /// <summary>Gets a value indicating whether Enabled.</summary>
+ public override bool Enabled
+ {
+ get
+ {
+ DbModelColumn column = HostWindow.DatabaseInspector.RightClickedModelObject as DbModelColumn;
+ return column != null && column.ForeignKeyReference != null;
+ }
+ }
+
+ /// <summary>Execute the command.</summary>
+ public override void Execute()
+ {
+ DbModelColumn column = HostWindow.DatabaseInspector.RightClickedModelObject as DbModelColumn;
+ if (column != null && column.ForeignKeyReference != null)
+ {
+ HostWindow.DatabaseInspector.NavigateTo(column.ForeignKeyReference.ReferenceColumn);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/ShowDatabaseInspectorCommand.cs b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/ShowDatabaseInspectorCommand.cs
new file mode 100644
index 0000000..bdf1fd0
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/ShowDatabaseInspectorCommand.cs
@@ -0,0 +1,34 @@
+#region License
+
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+#endregion
+
+using MiniSqlQuery.Core;
+using MiniSqlQuery.Core.Commands;
+using WeifenLuo.WinFormsUI.Docking;
+
+namespace MiniSqlQuery.PlugIns.DatabaseInspector.Commands
+{
+ /// <summary>The show database inspector command.</summary>
+ public class ShowDatabaseInspectorCommand : CommandBase
+ {
+ /// <summary>Initializes a new instance of the <see cref="ShowDatabaseInspectorCommand"/> class.</summary>
+ public ShowDatabaseInspectorCommand()
+ : base("Show Database Inspector")
+ {
+ }
+
+ /// <summary>Execute the command.</summary>
+ public override void Execute()
+ {
+ DockContent databaseInspector = Services.Resolve<IDatabaseInspector>() as DockContent;
+ if (databaseInspector != null)
+ {
+ HostWindow.ShowDatabaseInspector(databaseInspector as IDatabaseInspector, DockState.DockLeft);
+ databaseInspector.Activate();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/ShowFindObjectFormCommand.cs b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/ShowFindObjectFormCommand.cs
new file mode 100644
index 0000000..079ffe4
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/ShowFindObjectFormCommand.cs
@@ -0,0 +1,47 @@
+#region License
+
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+#endregion
+
+using System;
+using System.Linq;
+using System.Windows.Forms;
+using MiniSqlQuery.Core;
+using MiniSqlQuery.Core.Commands;
+
+namespace MiniSqlQuery.PlugIns.DatabaseInspector.Commands
+{
+ /// <summary>The show find object form command.</summary>
+ public class ShowFindObjectFormCommand : CommandBase
+ {
+ /// <summary>Initializes a new instance of the <see cref="ShowFindObjectFormCommand"/> class.</summary>
+ public ShowFindObjectFormCommand()
+ : base("Find Object...")
+ {
+ ShortcutKeys = Keys.Alt | Keys.F;
+ }
+
+ /// <summary>Execute the command.</summary>
+ public override void Execute()
+ {
+ using (var frm = Services.Resolve<FindObjectForm>())
+ {
+ frm.ShowDialog(HostWindow.Instance);
+
+ var selectedTableName = frm.SelectedObjectName;
+ if (frm.DialogResult == DialogResult.OK && !String.IsNullOrEmpty(selectedTableName))
+ {
+ // Special case for handling schemas - We want the search without the [dbo].[foo] part
+ // but the FindTableOrView expects it....
+ var parts = selectedTableName.Split('.').Select(s => "[" + s + "]").ToArray();
+ var name = String.Join(".", parts);
+
+ IDbModelNamedObject obj = HostWindow.DatabaseInspector.DbSchema.FindTableOrView(name);
+ HostWindow.DatabaseInspector.NavigateTo(obj);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/TruncateTableCommand.cs b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/TruncateTableCommand.cs
new file mode 100644
index 0000000..373535d
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery/PlugIns/DatabaseInspector/Commands/TruncateTableCommand.cs
@@ -0,0 +1,69 @@
+#region License
+
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+#endregion
+
+using System;
+using System.Data;
+using System.Data.Common;
+using System.Windows.Forms;
+using MiniSqlQuery.Core;
+
+namespace MiniSqlQuery.PlugIns.DatabaseInspector.Commands
+{
+ /// <summary>The truncate table command.</summary>
+ public class TruncateTableCommand : GenerateStatementCommandBase
+ {
+ /// <summary>Initializes a new instance of the <see cref="TruncateTableCommand"/> class.</summary>
+ public TruncateTableCommand()
+ : base("Truncate Table")
+ {
+ SmallImage = ImageResource.table_delete;
+ }
+
+ /// <summary>Execute the command.</summary>
+ public override void Execute()
+ {
+ IHostWindow hostWindow = Services.HostWindow;
+ string tableName = hostWindow.DatabaseInspector.RightClickedTableName;
+
+ string caption = string.Format("Truncate '{0}' Table Confirmation", tableName);
+ string msg = string.Format("Delete all '{0}' data, are you sure?", tableName);
+ if (tableName != null && MessageBox.Show(msg, caption, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ DbConnection dbConnection;
+ DbCommand cmd = null;
+
+ try
+ {
+ hostWindow.SetPointerState(Cursors.WaitCursor);
+ dbConnection = Settings.GetOpenConnection();
+ cmd = dbConnection.CreateCommand();
+ cmd.CommandText = "DELETE FROM " + tableName;
+ cmd.CommandType = CommandType.Text;
+ cmd.ExecuteNonQuery();
+ Services.PostMessage(SystemMessage.TableTruncated, tableName);
+ }
+ catch (DbException dbExp)
+ {
+ hostWindow.DisplaySimpleMessageBox(null, dbExp.Message, "Error");
+ }
+ catch (InvalidOperationException invalidExp)
+ {
+ hostWindow.DisplaySimpleMessageBox(null, invalidExp.Message, "Error");
+ }
+ finally
+ {
+ if (cmd != null)
+ {
+ cmd.Dispose();
+ }
+
+ hostWindow.SetPointerState(Cursors.Default);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file