Example #1
0
 /// <summary>
 /// Construct a SchemaChange event, used when parsing DDL events
 /// </summary>
 /// <param name="ddeID">Pointer to ddl event ID generated on the master</param>
 /// <param name="eventType">The type of event (i.e. Add, Drop, Modify, Rename a column)</param>
 /// <param name="schemaName">Database table schema name (i.e. dbo)</param>
 /// <param name="tableName">Table the change applies to</param>
 /// <param name="columnName">Column the change applies to </param>
 /// <param name="newColumnName">New column name (for rename events only)</param>
 /// <param name="dataType">Data type of the column (for modify/add events only)</param>
 public SchemaChange(int ddeID, SchemaChangeType eventType, string schemaName, string tableName, string columnName, string newColumnName, DataType dataType = null)
 {
     this.DdeID = ddeID;
     this.EventType = eventType;
     this.SchemaName = schemaName;
     this.TableName = tableName;
     this.ColumnName = columnName;
     this.NewColumnName = newColumnName;
     this.DataType = dataType;
 }
Example #2
0
 /// <summary>
 /// Constructor used on the slave side when reading published schema change events
 /// </summary>
 /// <param name="row">DataRow from querying schema change table</param>
 public SchemaChange(DataRow row)
 {
     DdeID = row.Field<int>("CscDdeID");
     EventType = (SchemaChangeType)Enum.Parse(typeof(SchemaChangeType), row.Field<string>("CscEventType"));
     SchemaName = row.Field<string>("CscSchema");
     TableName = row.Field<string>("CscTableName");
     ColumnName = row.Field<string>("CscColumnName");
     NewColumnName = row.Field<string>("CscNewColumnName");
     DataType = new DataType(row.Field<string>("CscBaseDataType"), row.Field<int?>("CscCharacterMaximumLength"),
         row.Field<int?>("CscNumericPrecision"), row.Field<int?>("CscNumericScale"));
 }
Example #3
0
 /// <summary>
 /// Compare two DataType objects that may both be null. Used for unit tests
 /// </summary>
 /// <param name="expected">Expected data type</param>
 /// <param name="actual">Actual data type</param>
 /// <returns>True if the objects are equal or both null</returns>
 public static bool Equals(DataType expected, DataType actual)
 {
     if (expected == null && actual == null) {
         return true;
     }
     if (expected == null || actual == null) {
         return false;
     }
     if (expected.BaseType != actual.BaseType
         || expected.CharacterMaximumLength != actual.CharacterMaximumLength
         || expected.NumericPrecision != actual.NumericPrecision
         || expected.NumericScale != actual.NumericScale
         ) {
         return false;
     }
     return true;
 }