/// <inheritdoc/> public ColumnInfo CreateNewColumnInfo(ITableInfo parent, DiscoveredColumn discoveredColumn) { var toAdd = new ColumnInfo((ICatalogueRepository)parent.Repository, discoveredColumn.GetFullyQualifiedName(), discoveredColumn.DataType.SQLType, parent); toAdd.Format = discoveredColumn.Format; toAdd.Collation = discoveredColumn.Collation; toAdd.IsPrimaryKey = discoveredColumn.IsPrimaryKey; toAdd.IsAutoIncrement = discoveredColumn.IsAutoIncrement; toAdd.SaveToDatabase(); return(toAdd); }
private void Add(DiscoveredColumn discoveredColumn) { if (items.Any(i => i.Tag.Equals(discoveredColumn))) { return; } var snip = new SubstringAutocompleteItem(discoveredColumn.GetRuntimeName()); snip.MenuText = discoveredColumn.GetRuntimeName(); //name of table snip.Text = discoveredColumn.GetFullyQualifiedName(); //full SQL snip.Tag = discoveredColumn; //record object for future reference snip.ImageIndex = GetIndexFor(discoveredColumn, RDMPConcept.ColumnInfo.ToString()); AddUnlessDuplicate(snip); }
/// <inheritdoc/> public ColumnInfo CreateNewColumnInfo(ITableInfo parent, DiscoveredColumn discoveredColumn) { var col = new ColumnInfo((ICatalogueRepository)parent.Repository, discoveredColumn.GetFullyQualifiedName(), discoveredColumn.DataType.SQLType, parent); //if it has an explicitly specified format (Collation) col.Format = discoveredColumn.Format; //if it is a primary key col.IsPrimaryKey = discoveredColumn.IsPrimaryKey; col.IsAutoIncrement = discoveredColumn.IsAutoIncrement; col.Collation = discoveredColumn.Collation; col.SaveToDatabase(); return(col); }
/// <summary> /// Returns the SQL string <paramref name="col"/>=<paramref name="value"/> /// </summary> /// <param name="col">LHS argument</param> /// <param name="value">RHS argument, if null then string literal "null" is used</param> /// <param name="op">The SQL operator to use, if null "=" is used</param> /// <returns></returns> protected string GetFieldEqualsValueExpression(DiscoveredColumn col, string value, string op) { StringBuilder builder = new StringBuilder(); builder.Append(col.GetFullyQualifiedName()); builder.Append(" "); builder.Append(op ?? "="); builder.Append(" "); if (string.IsNullOrWhiteSpace(value)) { builder.Append("null"); } else { builder.Append(value); } return(builder.ToString()); }
public IEnumerable <string> GetWhitelist() { var colName = _column.GetRuntimeName(); using (var con = _discoveredTable.Database.Server.GetConnection()) { con.Open(); var cmd = _discoveredTable.GetCommand("Select DISTINCT " + _column.GetFullyQualifiedName() + " FROM " + _discoveredTable.GetFullyQualifiedName(), con); var r = cmd.ExecuteReader(); while (r.Read()) { var o = r[colName] as string; if (o != null) { yield return(o.Trim()); } } } }