public UpdateStatement (IdentifierExpression identifier, IEnumerable<IdentifierExpression> columns, IEnumerable<IExpression> values)
		{
			Identifier = identifier;
			
			this.columns = new List<IdentifierExpression> ();
			this.values = new List<IExpression> ();
			
			this.columns.AddRange (columns);
			this.values.AddRange (values);
		}
		public InsertStatement (IdentifierExpression identifier, IEnumerable<IdentifierExpression> columns, IEnumerable<IEnumerable<IExpression>> values)
		{
			Identifier = identifier;
			
			this.columns = new List<IdentifierExpression> ();
			this.values = new List<List<IExpression>> ();
			
			this.columns.AddRange (columns);
			foreach (IEnumerable<IExpression> row in values) {
				List<IExpression> expr = new List<IExpression> ();
				expr.AddRange (row);
				this.Values.Add (expr);
			}
		}
		protected void OnEmptyTable ()
		{
			TableNode node = (TableNode)CurrentNode.DataItem;

			if (Services.MessageService.AskQuestion (
				GettextCatalog.GetString ("Are you sure you want to empty table '{0}'", node.Table.Name),
				GettextCatalog.GetString ("Empty Table")
			)) {
				IdentifierExpression tableId = new IdentifierExpression (node.Table.Name);
				DeleteStatement del = new DeleteStatement (new FromTableClause (tableId));
				
				IPooledDbConnection conn = node.ConnectionContext.ConnectionPool.Request ();
				IDbCommand command = conn.CreateCommand (del);
				conn.ExecuteNonQueryAsync (command, new ExecuteCallback<int> (OnEmptyTableCallback), null);
			}
		}
		protected void OnSelectAllCommand ()
		{
			TableNode node = (TableNode)CurrentNode.DataItem;
			
			IdentifierExpression tableId = new IdentifierExpression (node.Table.Name);
			SelectStatement sel = new SelectStatement (new FromTableClause (tableId));

			IPooledDbConnection conn = node.ConnectionContext.ConnectionPool.Request ();
			IDbCommand command = conn.CreateCommand (sel);
			conn.ExecuteTableAsync (command, new ExecuteCallback<DataTable> (OnSelectCommandThreaded), null);
		}
		private void OnSelectColumnsCommandGetColumns (object state)
		{
			TableNode node = (TableNode)state;
			
			ColumnSchemaCollection columns = node.Table.Columns; //this can invoke the schema provider, so it must be in bg thread
			
			DispatchService.GuiDispatch (delegate () {
				SelectColumnDialog dlg = new SelectColumnDialog (true, columns);
				if (dlg.Run () == (int)Gtk.ResponseType.Ok) {
					IdentifierExpression tableId = new IdentifierExpression (node.Table.Name);
					List<IdentifierExpression> cols = new List<IdentifierExpression> ();
					foreach (ColumnSchema schema in dlg.CheckedColumns)
						cols.Add (new IdentifierExpression (schema.Name));
					
					SelectStatement sel = new SelectStatement (new FromTableClause (tableId), cols);

					IPooledDbConnection conn = node.ConnectionContext.ConnectionPool.Request ();
					IDbCommand command = conn.CreateCommand (sel);
					
					conn.ExecuteTableAsync (command, new ExecuteCallback<DataTable> (OnSelectCommandThreaded), null);
				}
				dlg.Destroy ();
			});
		}
		protected void OnQueryCommand ()
		{
			TableNode node = (TableNode)CurrentNode.DataItem;
			
			IdentifierExpression tableId = new IdentifierExpression (node.Table.Name);
			SelectStatement sel = new SelectStatement (new FromTableClause (tableId));
			
			SqlQueryView view = new SqlQueryView ();
			view.SelectedConnectionContext = node.ConnectionContext;
			
			IDbFactory fac = DbFactoryService.GetDbFactory (node.ConnectionContext.ConnectionSettings);
			view.Text = fac.Dialect.GetSql (sel);

			IdeApp.Workbench.OpenDocument (view, true);
		}
示例#7
0
		protected virtual string GetExpressionSql (IdentifierExpression expr)
		{
			return GetIdentifierName (expr.Name);
		}
		public DropStatement (IdentifierExpression identifier, DropStatementType dropType)
		{
			Identifier = identifier;
			DropType = dropType;
		}
示例#9
0
		public FromTableClause (IdentifierExpression source)
		{
			Source = source;
		}
示例#10
0
 public DropStatement(IdentifierExpression identifier, DropStatementType dropType)
 {
     Identifier = identifier;
     DropType   = dropType;
 }
		public TruncateStatement (IdentifierExpression identifier)
		{
			Identifier = identifier;
		}
		public virtual string GetUpdateQuery (TableSchema table)
		{
			ISqlDialect dialect =  this.ConnectionPool.DbFactory.Dialect;
			IdentifierExpression tableId = new IdentifierExpression (table.Name);
			List<IdentifierExpression> columns = new List<IdentifierExpression>();
			List<IExpression> values = new List<IExpression>();
			
			foreach (ColumnSchema col in table.Columns) {
				columns.Add(new IdentifierExpression(col.Name));				
				values.Add(new IdentifierExpression(col.DataTypeName));				
			}
			
			UpdateStatement upd = new UpdateStatement (tableId, columns, values);
			return dialect.GetSql(upd);
		}
		public virtual string GetSelectQuery (TableSchema table)
		{
			ISqlDialect dialect =  this.ConnectionPool.DbFactory.Dialect;
			IdentifierExpression tableId = new IdentifierExpression (table.Name);
			List<IdentifierExpression> columns = new List<IdentifierExpression>();
			
			foreach (ColumnSchema col in table.Columns) {
				columns.Add(new IdentifierExpression(col.Name));
			}
			
			SelectStatement sel = new SelectStatement (new FromTableClause (tableId),columns);
			return dialect.GetSql(sel);
		}
示例#14
0
 protected virtual string GetExpressionSql(IdentifierExpression expr)
 {
     return(GetIdentifierName(expr.Name));
 }
示例#15
0
 public TruncateStatement(IdentifierExpression identifier)
 {
     Identifier = identifier;
 }