bool ITablePart.HasChanges() { if (!ObjectHelper.AreEqual(this, oldIndex)) { return(true); } if (Columns.Count != oldIndex.Columns.Count) { return(true); } foreach (IndexColumn ic in Columns) { int i = 0; for (; i < oldIndex.Columns.Count; i++) { IndexColumn oic = oldIndex.Columns[i]; if (oic.ColumnName == ic.ColumnName && oic.SortOrder == ic.SortOrder) { break; } } if (i == oldIndex.Columns.Count) { return(true); } } return(false); }
void ITablePart.Saved() { oldIndex.Comment = Comment; oldIndex.FullText = FullText; oldIndex.IndexUsing = IndexUsing; oldIndex.IsPrimary = IsPrimary; oldIndex.IsUnique = IsUnique; oldIndex.KeyBlockSize = KeyBlockSize; oldIndex.Name = Name; oldIndex.Parser = Parser; oldIndex.Spatial = Spatial; oldIndex.Type = Type; // now we need to copy the columns oldIndex.Columns.Clear(); foreach (IndexColumn ic in Columns) { IndexColumn old = new IndexColumn(); old.ColumnName = ic.ColumnName; old.SortOrder = ic.SortOrder; old.OwningIndex = oldIndex; oldIndex.Columns.Add(old); } }
private void addButton_Click(object sender, EventArgs e) { Index index = table.CreateIndexWithUniqueName(false); IndexColumn ic = new IndexColumn(); ic.OwningIndex = index; ic.ColumnName = table.Columns[0].ColumnName; ic.SortOrder = IndexSortOrder.Ascending; index.Columns.Add(ic); table.Indexes.Add(index); indexList.SelectedIndex = indexList.Items.Add(index.Name); }
private void ParseIndexInfo(DataRow indexData) { Name = indexData["INDEX_NAME"].ToString(); IsPrimary = (bool)indexData["PRIMARY"]; IsUnique = (bool)indexData["UNIQUE"] || IsPrimary; Comment = indexData["COMMENT"].ToString(); string type = indexData["TYPE"].ToString(); switch (type) { case "BTREE": IndexUsing = IndexUsingType.BTREE; break; case "RTREE": IndexUsing = IndexUsingType.RTREE; break; case "HASH": IndexUsing = IndexUsingType.HASH; break; } FullText = type == "FULLTEXT"; Spatial = type == "SPATIAL"; string[] restrictions = new string[5] { null, table.OwningNode.Database, table.Name, Name, null }; DataTable dt = table.OwningNode.GetSchema("IndexColumns", restrictions); foreach (DataRow row in dt.Rows) { IndexColumn col = new IndexColumn(); col.OwningIndex = this; col.ColumnName = row["COLUMN_NAME"].ToString(); string sortOrder = row["SORT_ORDER"].ToString(); // if (sortOrder == "D") // col.SortOrder = IndexSortOrder.Descending; // else if (sortOrder == null) // col.SortOrder = IndexSortOrder.Unsorted; // else col.SortOrder = IndexSortOrder.Ascending; Columns.Add(col); } if (IsPrimary) { Type = IndexType.Key; } //KeyBlockSize //Parser }
private void ParseIndexInfo(DataRow indexData) { Name = indexData["INDEX_NAME"].ToString(); IsPrimary = (bool)indexData["PRIMARY"]; IsUnique = (bool)indexData["UNIQUE"] || IsPrimary; Comment = indexData["COMMENT"].ToString(); string type = indexData["TYPE"].ToString(); switch (type) { case "BTREE": IndexUsing = IndexUsingType.BTREE; break; case "RTREE": IndexUsing = IndexUsingType.RTREE; break; case "HASH": IndexUsing = IndexUsingType.HASH; break; } FullText = type == "FULLTEXT"; Spatial = type == "SPATIAL"; string[] restrictions = new string[5] { null, table.OwningNode.Database, table.Name, Name, null }; DataTable dt = table.OwningNode.GetSchema("IndexColumns", restrictions); foreach (DataRow row in dt.Rows) { IndexColumn col = new IndexColumn(); col.OwningIndex = this; col.ColumnName = row["COLUMN_NAME"].ToString(); string sortOrder = row["SORT_ORDER"].ToString(); // if (sortOrder == "D") // col.SortOrder = IndexSortOrder.Descending; // else if (sortOrder == null) // col.SortOrder = IndexSortOrder.Unsorted; // else col.SortOrder = IndexSortOrder.Ascending; Columns.Add(col); } if (IsPrimary) Type = IndexType.Key; //KeyBlockSize //Parser }
private void OnPrimaryKey(object sender, EventArgs e) { OleMenuCommand primaryKey = sender as OleMenuCommand; foreach (Column c in Columns) c.PrimaryKey = false; tableNode.Table.DeleteKey(null); // if not checked then we are setting the key columns if (!primaryKey.Checked) { Index index = tableNode.Table.CreateIndexWithUniqueName(true); List<int> rows = new List<int>(); foreach (DataGridViewRow row in columnGrid.SelectedRows) rows.Add(row.Index); if (columnGrid.SelectedRows.Count == 0) rows.Add(columnGrid.CurrentCell.RowIndex); foreach (int row in rows) { Columns[row].PrimaryKey = true; IndexColumn ic = new IndexColumn(); ic.OwningIndex = index; ic.ColumnName = Columns[row].ColumnName; ic.SortOrder = IndexSortOrder.Ascending; index.Columns.Add(ic); } if (index.Columns.Count > 0) Indexes.Add(index); } columnGrid.Refresh(); }
void ITablePart.Saved() { oldIndex.Comment = Comment; oldIndex.FullText = FullText; oldIndex.IndexUsing = IndexUsing; oldIndex.IsPrimary = IsPrimary; oldIndex.IsUnique = IsUnique; oldIndex.KeyBlockSize = KeyBlockSize; oldIndex.Name = Name; oldIndex.Parser = Parser; oldIndex.Spatial = Spatial; oldIndex.Type = Type; // now we need to copy the columns oldIndex.Columns.Clear(); foreach (IndexColumn ic in Columns) { IndexColumn old = new IndexColumn(); old.ColumnName = ic.ColumnName; old.SortOrder = ic.SortOrder; old.OwningIndex = oldIndex; oldIndex.Columns.Add(old); } }
private void okButton_Click(object sender, EventArgs e) { indexColumns.Clear(); foreach (IndexColumnGridRow row in gridRows) { if (String.IsNullOrEmpty(row.ColumnName)) continue; IndexColumn ic = new IndexColumn(); ic.ColumnName = row.ColumnName; ic.SortOrder = (IndexSortOrder)Enum.Parse(typeof(IndexSortOrder), row.SortOrder); indexColumns.Add(ic); } }