internal Column(DataRow row, Table source) { _table = source; _unique = new Unique(this, row); if (row.IsNull("AUTOINCREMENT") == false && (bool)row["AUTOINCREMENT"] == true) _table.PrimaryKey.AutoIncrement = true; _dataType = (row.IsNull("DATA_TYPE") == false) ? row["DATA_TYPE"].ToString() : String.Empty; _columnName = row["COLUMN_NAME"].ToString(); _origName = _columnName; _allowNulls = (bool)row["IS_NULLABLE"]; _defaultValue = (row.IsNull("COLUMN_DEFAULT") == false) ? row["COLUMN_DEFAULT"].ToString() : String.Empty; _collate = (row.IsNull("COLLATION_NAME") == false) ? row["COLLATION_NAME"].ToString() : String.Empty; string edmtype = (row.IsNull("EDM_TYPE") == false) ? row["EDM_TYPE"].ToString() : String.Empty; if (edmtype == "nvarchar" || edmtype == "varchar" || edmtype == "blob" || edmtype == "nchar" || edmtype == "char") { int size = (row.IsNull("CHARACTER_MAXIMUM_LENGTH") == false) ? Convert.ToInt32(row["CHARACTER_MAXIMUM_LENGTH"]) : int.MaxValue; if (size != int.MaxValue) _dataType = string.Format("{0}({1})", _dataType, size); } else if (edmtype == "decimal") { int size = (row.IsNull("NUMERIC_PRECISION") == false) ? Convert.ToInt32(row["NUMERIC_PRECISION"]) : 53; int scale = (row.IsNull("NUMERIC_SCALE") == false) ? Convert.ToInt32(row["NUMERIC_SCALE"]) : int.MaxValue; if (size != 53) { string scalestr = (scale == int.MaxValue) ? "" : String.Format(",{0}", scale); _dataType = string.Format("{0}({1}{2})", _dataType, size, scalestr); } } }
private ForeignKey(ForeignKey source) { _table = source._table; _from = new ForeignKeyFromItem(this, source._from.Column); _to = new ForeignKeyToItem(this, source._to.Catalog, source._to.Table, source._to.Column); _name = source._name; _dirty = source._dirty; }
public TableDesignerDoc(int itemId, DataViewHierarchyAccessor accessor, string tableName) { _accessor = accessor; _connection = accessor.Connection; _itemId = itemId; _init = true; InitializeComponent(); StringBuilder tables = new StringBuilder(); using (DataReader reader = _connection.Command.Execute("SELECT * FROM sqlite_master", 1, null, 30)) { while (reader.Read()) { tables.Append(reader.GetItem(2).ToString()); tables.Append(","); } } int n = 1; if (String.IsNullOrEmpty(tableName)) { string alltables = tables.ToString(); do { tableName = String.Format("Table{0}", n); n++; } while (alltables.IndexOf(tableName + ",", StringComparison.OrdinalIgnoreCase) > -1 || _editingTables.ContainsValue(tableName)); _editingTables.Add(GetHashCode(), tableName); } _table = new Table(tableName, _connection.ConnectionSupport.ProviderObject as DbConnection, this); foreach(Column c in _table.Columns) { n = _dataGrid.Rows.Add(); _dataGrid.Rows[n].Tag = c; c.Parent = _dataGrid.Rows[n]; } _init = false; if (_dataGrid.Rows.Count > 0) { _dataGrid.EndEdit(); _sqlText.Text = _table.OriginalSql; } }
internal ForeignKey(DbConnection cnn, Table table, DataRow row) { _table = table; if (row != null) { _from = new ForeignKeyFromItem(this, row["FKEY_FROM_COLUMN"].ToString()); _to = new ForeignKeyToItem(this, row["FKEY_TO_CATALOG"].ToString(), row["FKEY_TO_TABLE"].ToString(), row["FKEY_TO_COLUMN"].ToString()); _name = row["CONSTRAINT_NAME"].ToString(); } else { _name = null; _from = new ForeignKeyFromItem(this, ""); _to = new ForeignKeyToItem(this, _table.Catalog, "", ""); } }
internal PrimaryKey(DbConnection cnn, Table table, DataRow row) : base(cnn, table, row) { if (String.IsNullOrEmpty(_name) == false && _name.StartsWith("sqlite_", StringComparison.OrdinalIgnoreCase)) _name = null; }
internal Column(Table table, DataGridViewRow row) { _parent = row; _table = table as Table; _unique = new Unique(this); }
internal ForeignKeyEditor(Table parent) : base(typeof(List<ForeignKey>)) { _table = parent; _count = _table.ForeignKeys.Count; }
internal EditorHolder(Table tbl) { _indexes = tbl.Indexes; _fkeys = tbl.ForeignKeys; _check = tbl.Check; _triggers = tbl.Triggers as List<Trigger>; }
internal IndexEditor(Table parent) : base(typeof(List<Index>)) { _table = parent; }
protected Index(Index source) { _table = source._table; _name = source._name; _unique = source._unique; _definition = source._definition; _conflict = source._conflict; _dirty = source._dirty; foreach (IndexColumn c in source._columns) { IndexColumn copy = ((ICloneable)c).Clone() as IndexColumn; copy._parent = this; _columns.Add(copy); } }
internal Index(DbConnection cnn, Table table, DataRow index) { _table = table; if (index != null) { _name = index["INDEX_NAME"].ToString(); _unique = (bool)index["UNIQUE"]; _definition = index["INDEX_DEFINITION"].ToString(); using (DataTable tbl = cnn.GetSchema("IndexColumns", new string[] { table.Catalog, null, table.Name, Name })) { foreach (DataRow row in tbl.Rows) { _columns.Add(new IndexColumn(this, row)); } } } }
internal CheckEditor(Table parent) : base(typeof(List<string>)) { _table = parent; }