private SQLColumn[] PopulateColumns(SQLColumn[] columnsToAdd) { List <SQLColumn> newColumns = new List <SQLColumn>(); // // Run through our new columns and if any of our old ones match contiguously // from the start then we keep them (and their settings). int i = 0; for ( ; i < columnsToAdd.Length && i < _listControl.Columns.Count; i++) { SQLColumn oldColumn = (SQLColumn)_listControl.Columns[i]; if (columnsToAdd[i].IsSameColumn(oldColumn)) { columnsToAdd[i] = oldColumn; } else { newColumns.Add(columnsToAdd[i]); } } if (i < columnsToAdd.Length) { SQLColumn [] toCopy = new SQLColumn[columnsToAdd.Length - i]; Array.Copy(columnsToAdd, i, toCopy, 0, toCopy.Length); newColumns.AddRange(toCopy); } _listControl.Columns.Clear(); _listControl.Columns.AddRange(columnsToAdd); return(newColumns.ToArray()); }
private void _SQLColumn(SqlInstances sqlInstances) { if (0 == databases.Count) { sD = new SQLDatabase(credentials); sD.SetInstance(sqlInstances.ServerInstance); if (nodefaults) { sD.EnableNoDefaultsFilter(); } if (hasAccess) { sD.EnableHasAccessFilter(); } if (sysadmin) { sD.EnableSysAdminFilter(); } sD.Query(); databases = sD.GetResults(); } SQLColumn sC = new SQLColumn(credentials); sC.SetComputerName(sqlInstances.Server); sC.SetInstance(sqlInstances.ServerInstance); var results = new List <SQLColumn.Column>(); foreach (var d in sD.GetResults()) { sC.SetDatabase(d.DatabaseName); if (!string.IsNullOrEmpty(ColumnFilter)) { sC.SetColumnFilter(ColumnFilter); } if (!string.IsNullOrEmpty(ColumnSearchFilter)) { foreach (var c in ColumnSearchFilter.Split(',')) { sC.AddColumnSearchFilter(c); } } if (!string.IsNullOrEmpty(TableNameFilter)) { sC.SetTableNameFilter(TableNameFilter); } sC.Query(); results.AddRange(sC.GetResults()); } _PrintOutput(results); }
public bool IsSameColumn(SQLColumn otherColumn) { return(this.Name == otherColumn.Name && _columnIndex == otherColumn._columnIndex); }
public void TestSQLColumnOutputAutoIncrement() { SQLColumn testColumn = new SQLColumn("testColumnName", System.Data.SqlDbType.Int, false, new Tuple <int, int>(1, 1)); Assert.Equal("testColumnName Int IDENTITY(1,1) NOT NULL", testColumn.GetCreateSqlColumnInfo()); }
public void TestSQLColumnOutputAll() { SQLColumn testColumn = new SQLColumn("testColumnName", System.Data.SqlDbType.Binary, 255, false, true, new Tuple <int, int>(1, 1)); Assert.Equal("testColumnName Binary(255) IDENTITY(1,1) NOT NULL PRIMARY KEY", testColumn.GetCreateSqlColumnInfo()); }
public void TestSQLColumnOutputPrimaryKey() { SQLColumn testColumn = new SQLColumn("testColumnName", System.Data.SqlDbType.Int, false, true); Assert.Equal("testColumnName Int NOT NULL PRIMARY KEY", testColumn.GetCreateSqlColumnInfo()); }
public void TestSQLColumnOutputNull() { SQLColumn testColumn = new SQLColumn("testColumnName", System.Data.SqlDbType.Int, true); Assert.Equal("testColumnName Int NULL", testColumn.GetCreateSqlColumnInfo()); }
public void TestSQLColumnOutputDecimalSetPrecision() { SQLColumn testColumn = new SQLColumn("testColumnName", System.Data.SqlDbType.Decimal, new Tuple <int, int>(4, 2)); Assert.Equal("testColumnName Decimal(4,2) NOT NULL", testColumn.GetCreateSqlColumnInfo()); }
public void TestSQLColumnOutputDecimalDefault() { SQLColumn testColumn = new SQLColumn("testColumnName", System.Data.SqlDbType.Decimal); Assert.Equal("testColumnName Decimal(18,2) NOT NULL", testColumn.GetCreateSqlColumnInfo()); }
public void TestSQLColumnOutputVarCharSetLength() { SQLColumn testColumn = new SQLColumn("testColumnName", System.Data.SqlDbType.VarChar, 255); Assert.Equal("testColumnName VarChar(255) NOT NULL", testColumn.GetCreateSqlColumnInfo()); }