public Column(string name, DbType type, int size, ColumnProperty property) { Name = name; Type = type; Size = size; ColumnProperty = property; }
/// <summary> /// Method to get the column names /// </summary> /// <param name="mapItemCollection"></param> /// <param name="propertyToFetch"></param> /// <returns></returns> public string GetColumnNames(ColumnMapItemCollection mapItemCollection, ColumnProperty propertyToFetch) { if (mapItemCollection == null) { throw new ArgumentNullException("mapItemCollection"); } if (mapItemCollection.Count <= 0) { throw new ArgumentOutOfRangeException("mapItemCollection"); } StringBuilder builder = new StringBuilder(); switch (propertyToFetch) { case ColumnProperty.Source: foreach (ColumnMapItem columnMapItem in mapItemCollection) { builder.AppendFormat("{0},", columnMapItem.SourceColumn); } break; case ColumnProperty.Destination: foreach (ColumnMapItem columnMapItem in mapItemCollection) { builder.AppendFormat("{0},", columnMapItem.DestinationColumn); } break; default: builder.Append(","); break; } return builder.ToString().Substring(0, builder.Length - 1); }
public Column(string name, DbType type, ColumnProperty property, string collation) { Name = name; Type = type; ColumnProperty = property; Collation = collation; }
public Column(string name, DbType type, ColumnProperty property, object defaultValue) { Name = name; Type = type; ColumnProperty = property; DefaultValue = defaultValue; }
public Column(string name, ColumnType type, ColumnProperty property = ColumnProperty.None, object defaultValue = null) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException("name"); } if (type == null) { throw new ArgumentNullException("type"); } Name = name; ColumnType = type; ColumnProperty = property; DefaultValue = defaultValue; }
public SchemaBuilder WithProperty(ColumnProperty columnProperty) { _currentColumn.ColumnProperty = columnProperty; return this; }
public static bool PropertySelected(ColumnProperty source, ColumnProperty comparison) { return (source & comparison) == comparison; }
public static bool IsSelected(this ColumnProperty property, ColumnProperty test) { return (property & test) == test; }
void prop_GetColumnTitles(object sender, GetColumnTitlesEventArgs e) { if (e.DbName == "<blank>") { e.ColumnTitles = new ColumnPropertyCollection(); e.ColumnTitles.Add("检索点"); e.ColumnTitles.Add("数量"); return; } // e.ColumnTitles = this.MainForm.GetBrowseColumnNames(e.DbName); if (e.DbName.IndexOf("@") == -1) { e.ColumnTitles = new ColumnPropertyCollection(); ColumnPropertyCollection temp = this.MainForm.GetBrowseColumnProperties(e.DbName); if (temp != null) e.ColumnTitles.AddRange(temp); // 要复制,不要直接使用,因为后面可能会修改。怕影响到原件 } else { string strFormat = ""; if (this.m_biblioTable != null) { BiblioInfo info = this.m_biblioTable[e.DbName] as BiblioInfo; if (info != null) strFormat = info.Format; } e.ColumnTitles = new ColumnPropertyCollection(); string strColumnTitles = (string)_browseTitleTable[strFormat]; List<string> titles = StringUtil.SplitList(strColumnTitles, '\t'); foreach (string s in titles) { ColumnProperty property = new ColumnProperty(s); e.ColumnTitles.Add(property); } } if (this.m_bFirstColumnIsKey == true) e.ColumnTitles.Insert(0, "命中的检索点"); }
public void AddColumn(string name, DbType type, ColumnProperty property, object defaultValue) { AddColumn(new Column {Name=name, DbType = type, Property = property, DefaultValue = defaultValue}); }
/// <summary> /// <see cref="TransformationProvider.AddColumn(string, string, DbType, int, ColumnProperty, object)"> /// AddColumn(string, string, Type, int, ColumnProperty, object) /// </see> /// </summary> public virtual void AddColumn(string table, string column, DbType type, int size, ColumnProperty property) { AddColumn(table, column, type, size, property, null); }
/// <summary> /// Check that target property exists /// </summary> /// <param name="source"></param> /// <param name="comparison"></param> /// <returns></returns> public static bool HasProperty(this ColumnProperty source, ColumnProperty comparison) { return((source & comparison) == comparison); }
set => SetValue(ColumnProperty, value);
public Column(string name, DbType type, int size, ColumnProperty property, string collation, object defaultValue) { Name = name; Type = type; Size = size; ColumnProperty = property; DefaultValue = defaultValue; Collation = collation; }
public static ColumnProperty Clear(this ColumnProperty fruits, ColumnProperty flags) { return fruits & (~flags); }
public void AddColumn(string table, string column, DbType type, int size, ColumnProperty property, object defaultValue) { // No Op }
public void AddColumn(string table, string column, DbType type, int size, ColumnProperty property) { // No Op }
public void AddColumn(string table, string column, DbType type, int size, ColumnProperty property) { // No Op }
public void AddColumn(string table, string column, DbType type, ColumnProperty property) { _sqlServerTransformationProvider.AddColumn(table, column, type, property); }
/// <summary> /// <see cref="TransformationProvider.AddColumn(string, string, DbType, int, ColumnProperty, object)"> /// AddColumn(string, string, Type, int, ColumnProperty, object) /// </see> /// </summary> public virtual void AddColumn(string table, string column, DbType type, int size, ColumnProperty property) { AddColumn(table, column, type, size, property, null); }
public ColumnPropertyProxy(Database database, ColumnProperty column) { this.database = database; this.column = column; }
/// <summary> /// Add a new column to an existing table. /// </summary> /// <param name="table">Table to which to add the column</param> /// <param name="column">Column name</param> /// <param name="type">Date type of the column</param> /// <param name="size">Max length of the column</param> /// <param name="property">Properties of the column, see <see cref="ColumnProperty">ColumnProperty</see>,</param> /// <param name="defaultValue">Default value</param> public virtual void AddColumn(string table, string column, DbType type, int size, ColumnProperty property, object defaultValue) { ColumnPropertiesMapper mapper = _dialect.GetAndMapColumnProperties(new Column(column, type, size, property, defaultValue)); AddColumn(table, mapper.ColumnSql); }
private void SyncEntry(SyncJn sync, Table obj, List <ColumnProperty> updateColumnProperties, DatabaseType from, DatabaseType to) { switch (sync.JnOperation) { case "INSERT": try { DataRow row; if (obj.GetType().Equals(typeof(HauspaketAttributZuord))) { row = GetSingleDataRowForMultiPk(sync.JnChangesetJson, sync.JnTable, "hauspaket_id", "wert_id", from); } else { row = GetSingleDataRow(sync.JnPk, sync.JnTable, obj.GetPrimaryKeyColumn(), from); } DatabaseClientFactory.GetClient(to).ExecuteQuery(obj.GetInsertString(row, to), null); } catch (Exception e) { string message = "Error inserting " + obj.GetTableName() + " from " + from + ": " + e.Message + " on JN ID: " + sync.JnId; Logger.Error(message); AddErrorLog(message); } break; case "UPDATE": try { DataRow row; if (obj.GetType().Equals(typeof(HauspaketAttributZuord))) { row = GetSingleDataRowForMultiPk(sync.JnChangesetJson, sync.JnTable, "hauspaket_id", "wert_id", from); } else { row = GetSingleDataRow(sync.JnPk, sync.JnTable, obj.GetPrimaryKeyColumn(), from); } string query = obj.GetUpdateString(); ColumnProperty last = updateColumnProperties.Last(); foreach (ColumnProperty columnProperty in updateColumnProperties) { query = Table.AddUpdateParam(query, columnProperty.ColumnName, row[columnProperty.index], to, columnProperty.dataType, columnProperty.Equals(last)); } if (obj.GetType().Equals(typeof(HauspaketAttributZuord))) { string[] parts = sync.JnChangesetJson.Split(';'); Nullable <int> pk1 = new Nullable <int>(Int32.Parse(parts[2])); Nullable <int> pk2 = new Nullable <int>(Int32.Parse(parts[3])); query = query + " where hauspaket_id = " + pk1.Value + " and wert_id = " + pk2; } else { query = query + " where " + obj.GetWherePk(sync.JnPk.Value); } DatabaseClientFactory.GetClient(to).ExecuteQuery(query, null); } catch (Exception e) { string message = "Error updating " + obj.GetTableName() + " from " + from + ": " + e.Message + " on JN ID: " + sync.JnId; Logger.Error(message); AddErrorLog(message); } break; case "DELETE": try { if (obj.GetType().Equals(typeof(HauspaketAttributZuord))) { string[] parts = sync.JnChangesetJson.Split(';'); Nullable <int> pk1 = new Nullable <int>(Int32.Parse(parts[0])); Nullable <int> pk2 = new Nullable <int>(Int32.Parse(parts[1])); DatabaseClientFactory.GetClient(to).ExecuteQuery("delete from hauspaket_attribut_zuord where hauspaket_id = " + pk1 + " and wert_id = " + pk2, null); } else { DatabaseClientFactory.GetClient(to).ExecuteQuery(obj.getDeleteString(sync.JnPk.Value), null); } } catch (Exception e) { string message = "Error deleting " + obj.GetTableName() + " from " + from + ": " + e.Message + " on JN ID: " + sync.JnId; Logger.Error(message); AddErrorLog(message); } break; } SetSynced(sync, from); }
public void AddColumn(string table, string column, DbType type, int size, ColumnProperty property, object defaultValue) { _sqlServerTransformationProvider.AddColumn(table, column, type, size, property, defaultValue); }
public bool LoadCollection <C>() where C : UnifiedIMObject <C> { string collection = UnifiedCollectionAttribute.GetCollection <C>(); if (string.IsNullOrEmpty(collection)) { throw new Exception($"Missing UnifiedCollectionAttribute on type {typeof(C).Name}"); } TableCache.Add(typeof(C), collection); ColumnCache.Add(typeof(C), ColumnProperty.GetCollumns <C>(MySQLHelper.Instance, true, "ObjectID").Values.ToList()); ColumnProperty objidcol = GetColumns <C>().FirstOrDefault(X => X.Name == "ObjectID"); foreach (ColumnProperty prop in GetColumns <C>()) { if (prop.Name == "ObjectID") { prop.OverrideSqlType("char(32)"); } else { prop.OverrideSqlType(MySQLHelper.Instance.GetSqlType(prop.Type, prop.Column)); } } if (!MySQLTable.GetTables(SQL).Contains(collection)) { try { MySQLTable.CreateTable(SQL, collection, GetColumns <C>()); } catch (Exception ex) { throw new Exception($"Failed to create table {collection}"); } } else { MySQLTable table = MySQLTable.GetTable(SQL, collection); List <ColumnProperty> todo = table.Columns.ToList(); foreach (ColumnProperty col in GetColumns <C>()) { ColumnProperty existing = table.Columns.FirstOrDefault(X => X.Name == col.Name); if (existing == null) { System.Console.WriteLine($"SQL missing Column {col.Name}... Adding"); try { MySQLTable.AddColumn(SQL, collection, col.Name, col.SqlType); } catch (Exception ex) { throw new Exception($"Failed to add collumn {col.Name}\n{ex.Message}"); } } else if (!existing.SqlType.StartsWith(col.SqlType)) { System.Console.WriteLine($"SQL incorrect Column Type for {col.Name}... Converting"); try { MySQLTable.ConvertColumn(SQL, collection, col.Name, col.SqlType); } catch (Exception ex) { throw new Exception($"Failed to convert collumn {col.Name}\n{ex.Message}"); } } if (existing != null) { todo.Remove(existing); } } foreach (ColumnProperty prop in todo) { System.Console.WriteLine($"Excess collumn {prop.Name}... Removing"); try { MySQLTable.RemoveColumn(SQL, collection, prop.Name); } catch (Exception ex) { throw new Exception($"Failed to remove collumn {prop.Name}\n{ex.Message}"); } } } return(true); }
public override void AddColumn(string table, string column, DbType type, int size, ColumnProperty property) { base.AddColumn(table, column, type, size, property); }
public static bool PropertySelected(ColumnProperty source, ColumnProperty comparison) { return((source & comparison) == comparison); }
public void AddColumn(string name, DbType type, int size, ColumnProperty prop) { AddColumn(new Column { Name = name, DbType = type, Size = size, Property = prop }); }
public string SqlForProperty(ColumnProperty property) { if (propertyMap.ContainsKey(property)) { return propertyMap[property]; } return String.Empty; }
/// <summary> /// Initializes a new instance of the <see cref="Column"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="type">The type.</param> /// <param name="property">The property.</param> /// <param name="defaultValue">The default value.</param> public Column(string name, DbType type, ColumnProperty property, object defaultValue) : this(name, type) { ColumnProperty = property; DefaultValue = defaultValue; }
public SchemaBuilder WithProperty(ColumnProperty columnProperty) { _currentColumn.ColumnProperty = columnProperty; return(this); }
public void RegisterProperty(ColumnProperty property, string sql) { if (! propertyMap.ContainsKey(property)) { propertyMap.Add(property, sql); } propertyMap[property] = sql; }
/// <summary> /// Initializes a new instance of the <see cref="Column"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="type">The type.</param> /// <param name="property">The property.</param> public Column(string name, ColumnType type, ColumnProperty property) : this(name, type) { ColumnProperty = property; }
private void AddValueIfSelected(Column column, ColumnProperty property, ICollection<string> vals) { if (PropertySelected(column.ColumnProperty, property)) vals.Add(dialect.SqlForProperty(property)); }
/// <summary> /// Проверяет, выбрано ли заданное свойство /// </summary> /// <param name="source"></param> /// <param name="comparison"></param> /// <returns></returns> public static bool HasProperty(this ColumnProperty source, ColumnProperty comparison) { return (source & comparison) == comparison; }
/// <summary> /// Adds column property. /// </summary> /// <param name="property">The column property.</param> /// <returns>column instance.</returns> public Column AddProperty(ColumnProperty property) { ColumnProperties |= property; return this; }
/// <summary> /// Removes column property. /// </summary> /// <param name="property">The column property.</param> /// <returns>column instance.</returns> public Column RemoveProperty(ColumnProperty property) { ColumnProperties &= ~property; return this; }
public void AddColumn(string table, string column, DbType type, int size, ColumnProperty property, object defaultValue) { // No Op }
private void AddProperty(ColumnProperty property, bool value) { if (value) { AddProperty(property); } }
/// <summary> /// Add a new column to an existing table. /// </summary> /// <param name="table">Table to which to add the column</param> /// <param name="column">Column name</param> /// <param name="type">Date type of the column</param> /// <param name="size">Max length of the column</param> /// <param name="property">Properties of the column, see <see cref="ColumnProperty">ColumnProperty</see>,</param> /// <param name="defaultValue">Default value</param> public virtual void AddColumn(string table, string column, DbType type, int size, ColumnProperty property, object defaultValue) { if (ColumnExists(table, column)) { Logger.Warn("Column {0}.{1} already exists", table, column); return; } ColumnPropertiesMapper mapper = _dialect.GetAndMapColumnProperties(new Column(column, type, size, property, defaultValue)); AddColumn(table, mapper.ColumnSql); }
public static bool Match(this ColumnProperty prop, ColumnProperty compare) { return (prop & compare) == compare; }
void prop_GetColumnTitles(object sender, GetColumnTitlesEventArgs e) { if (e.DbName == "<blank>") { e.ColumnTitles = new ColumnPropertyCollection(); e.ColumnTitles.Add("检索点"); e.ColumnTitles.Add("数量"); return; } if (e.DbName.IndexOf("@") == -1) e.ColumnTitles = this.MainForm.GetBrowseColumnProperties(e.DbName); else { string strFormat = ""; if (this.m_biblioTable != null) { BiblioInfo info = this.m_biblioTable[e.DbName] as BiblioInfo; if (info != null) strFormat = info.Format; } e.ColumnTitles = new ColumnPropertyCollection(); string strColumnTitles = (string)_browseTitleTable[strFormat]; List<string> titles = StringUtil.SplitList(strColumnTitles, '\t'); foreach (string s in titles) { ColumnProperty property = new ColumnProperty(s); e.ColumnTitles.Add(property); } } }
/// <summary> /// Add a new column to an existing table. /// </summary> /// <param name="table">Table to which to add the column</param> /// <param name="column">Column name</param> /// <param name="type">Date type of the column</param> /// <param name="size">Max length of the column</param> /// <param name="property">Properties of the column, see <see cref="ColumnProperty">ColumnProperty</see>,</param> /// <param name="defaultValue">Default value</param> public virtual void AddColumn(string table, string column, DbType type, int size, ColumnProperty property, object defaultValue) { if (ColumnExists(table, column)) { Logger.Warn("Column {0}.{1} already exists", table, column); return; } ColumnPropertiesMapper mapper = _dialect.GetAndMapColumnProperties(new Column(column, type, size, property, defaultValue)); AddColumn(table, mapper.ColumnSql); }